Does Python's time.time() return a timestamp in UTC? -
this question has answer here:
i need generate unix timestamp in utc time i'm using time.time()
produce it.
need else or timestamp automatically in utc?
technically, time.time()
doesn't specify, , practically, @ least in cpython, returns timestamp in whatever format used underlying standard c library's time
function.
the c standard (which isn't freely available) doesn't whether gmt, , neither posix standard. says:
the
time()
function shall return value of time in seconds since epoch.
… without saying timezone, except can pass localtime
or gmtime
"broken-down time" in local or gmt timezones.
so, platform-specific. platform can return wants time
, long in way makes localtime
, gmtime
work properly.
that being said, it's usually going gmt—or, rather, either utc (windows), or utc-except-for-leap-seconds (most other platforms). example, freebsd says:
the
time()
function returns value of time in seconds since 0 hours, 0 minutes, 0 seconds, january 1, 1970, coordinated universal time, without including leap seconds.
os x , other *bsds have same manpage, windows , linux/glibc return utc (with or without leap seconds), etc.
also, python documentation says:
to find out epoch is, @
gmtime(0)
.
putting definitions time
, gmtime
, more work platform return local timestamps gmt. (that being said, statement can't authoritative, because it's not quite true posix platform, leap seconds.)
Comments
Post a Comment