time.gmtime

A

asit

we know that time.gmtime(secs) takes a parameter secs. what does this
secs suggest ??What is it's significance ??
 
H

Harald Karner

asit said:
we know that time.gmtime(secs) takes a parameter secs. what does this
secs suggest ??What is it's significance ??
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.
 
P

Paul Boddie

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top