time.gmtime

Paul Boddie paul at boddie.org.uk
Fri Jan 25 12:04:34 CET 2008


On 25 Jan, 11:43, asit <lipu... at gmail.com> wrote:
> we know that time.gmtime(secs) takes a parameter secs. what does this
> secs suggest ??What is it's significance ??

>From the documentation [1] with some editing:

"""
gmtime([secs])

Convert a time expressed in seconds since the epoch to a time
structure employing UTC. If secs is not provided or None, the current
time as returned by time.time() is used.

The epoch is the point where the time starts. On January 1st of that
year, at 0 hours, the ``time since the epoch'' is zero. For Unix, the
epoch is 1970. To find out what the epoch is, look at gmtime(0).
"""

So, the significance of the secs parameter is that it indicates a
specific point in time. Generally, you'll get this from functions like
time.time or from "UNIX timestamps" stored in things like files and
databases where people have wanted to indicate a point in time without
having to mention things like dates, times and timezones.

Paul

P.S. The datetime module is preferable to the time module, really. The
latter can drive you quite mad when things like timezones start to be
taken into account.

[1] http://docs.python.org/lib/module-time.html



More information about the Python-list mailing list