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
  • 17,446
  • 14
  • 72
  • 116
user2739823
  • 377
  • 1
  • 6
  • 21

2 Answers2

4
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(1394369201000/1000.0)
datetime.datetime(2014, 3, 9, 12, 46, 41)
MattH
  • 35,418
  • 10
  • 81
  • 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
  • 21,211
  • 8
  • 48
  • 73