0

I have this value returned from server 1394369201000 and I have to convert it to GWT date format? I have found different ways in documentation to fix this:

dt = datetime.datestr(1394369201000 , 'yyyymmdd')

but this didn't work.

Could you please, help me to fix this?

manlio
  • 18,345
  • 14
  • 76
  • 126
user2739823
  • 397
  • 1
  • 7
  • 24

2 Answers2

4
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(1394369201000/1000.0)
datetime.datetime(2014, 3, 9, 12, 46, 41)
MattH
  • 37,273
  • 11
  • 82
  • 84
2

Your time is perhaps in milliseconds, use time module:

In [33]: import time

In [34]: time.gmtime(1394369201000/1000.)
Out[34]: time.struct_time(tm_year=2014, tm_mon=3, tm_mday=9, tm_hour=12, tm_min=46, tm_sec=41, tm_wday=6, tm_yday=68, tm_isdst=0)
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108