2

I got some date online, and it's date string is pretty strange to me, for example:

'/Date(1506700800000)/'

I do not know how to parse, the integer string is not real time stamp, if I parse is in python using

time_stamp = "1506700800000"
datetime.fromtimestamp(int(time_stamp)).strftime('%Y-%m-%d')

I got wrong year, so I assume that's not a legal time stamp

As i am using Visual Studio to debug Python code, the Visual Studio watch windows show me the right time to be : 09/29/2017 16:00:00 automatically.

But I have no idea how VS does this conversion. I search on Google for long time but still not able to solve this problem, any help would be appreciated.

Chunde Huang
  • 337
  • 3
  • 9

1 Answers1

3

try this

import datetime
ms="1506700800000"
datetime.datetime.fromtimestamp(int(ms)/1000.0)
#if you want in string
datetime.datetime.fromtimestamp(int(ms)/1000.0).strftime("%Y-%m-%d %H:%M:%S")

output

datetime.datetime(2017, 9, 29, 21, 30)

output in string 2017-09-29 21:30:00

pushpendra chauhan
  • 2,205
  • 3
  • 20
  • 29