time.gmtime

Discussion in 'Python' started by asit, Jan 25, 2008.

  1. asit

    asit Guest

    we know that time.gmtime(secs) takes a parameter secs. what does this
    secs suggest ??What is it's significance ??
    asit, Jan 25, 2008
    #1
    1. Advertising

  2. asit wrote:
    > we know that time.gmtime(secs) takes a parameter secs. what does this
    > secs suggest ??What is it's significance ??


    >>> import time
    >>> help (time.gmtime)

    Help on built-in function gmtime in module time:

    gmtime(...)
    gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,
    tm_sec, tm_wday, tm_yday, tm_isdst)

    Convert seconds since the Epoch to a time tuple expressing UTC
    (a.k.a. GMT). When 'seconds' is not passed in, convert the current time
    instead.

    >>> time.gmtime (0)

    (1970, 1, 1, 0, 0, 0, 3, 1, 0)
    >>>
    Harald Karner, Jan 25, 2008
    #2
    1. Advertising

  3. asit

    Paul Boddie Guest

    On 25 Jan, 11:43, asit <> 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
    Paul Boddie, Jan 25, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen
    Replies:
    1
    Views:
    1,201
    Purl Gurl
    May 19, 2004
  2. KW
    Replies:
    1
    Views:
    1,804
    Eric Sosman
    Dec 8, 2004
  3. Leendert Bottelberghs

    time zone offset calc with localtime and gmtime

    Leendert Bottelberghs, Apr 4, 2005, in forum: Perl Misc
    Replies:
    11
    Views:
    763
    Mothra
    Apr 5, 2005
  4. Replies:
    0
    Views:
    107
  5. Replies:
    1
    Views:
    108
    Anssi Saari
    Sep 18, 2013
Loading...

Share This Page