I am parsing a JSON file in Python 2.7 that includes
"TimestampUtc":"\/Date(1477393888000)\/
and I want to parse this file and convert the date into :
8:11 a.m. Oct. 25, 2016
The original time zone is in the US and I want to get exactly the same output. But this format is not that common and other similar questions don't answer it. Is there any idea how to do it ?
you can try:
>>> from datetime import datetime
>>> d = "1467717221000"
>>> d = int(d[:10])
>>> datetime.fromtimestamp(d).strftime('%Y-%m-%d %I:%M:%S %p')
'2016-07-05 04:43:41 PM'
edit: Format update :
>>> datetime.fromtimestamp(d).strftime(' %I:%M %p %b. %d, %y').replace("PM","p.m.").replace("AM","a.m.")
' 04:43 p.m. 07. 05, 16'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With