1

I use python's time module to convert time_struct and timestamp:

mktime(gmtime(1404144000))

result is :

1404115200.0

who can tell me why?

doniyor
  • 36,596
  • 57
  • 175
  • 260
user2848932
  • 776
  • 1
  • 14
  • 28
  • what result do you want ? mktime returns a floating point number, for compatibility with time(). – scx Aug 06 '14 at 12:22

2 Answers2

1

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?

Community
  • 1
  • 1
nicolas
  • 3,120
  • 2
  • 15
  • 17
0

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
coder.in.me
  • 1,048
  • 9
  • 19