I use python's time module to convert time_struct and timestamp:
mktime(gmtime(1404144000))
result is :
1404115200.0
who can tell me why?
I use python's time module to convert time_struct and timestamp:
mktime(gmtime(1404144000))
result is :
1404115200.0
who can tell me why?
mktime()
is the inverse of localtime()
, not gmtime()
To get the inverse of gmtime()
, see this question:
Is there an inverse function for time.gmtime() that parses a UTC tuple to seconds since the epoch?
mktime() takes a time tuple whose value is in localtime. Hence, this will give you the correct answer:
mktime(localtime(1404144000))
If you wish to operate on a time tuple in UTC, then conversion can be done by specifying the timezone:
mktime(gmtime(1404144000))-timezone