Convert time stamp to combined date and time in UTC in Python -


i pulled data api in json format. data contains unix time stamp , information timezone. question how add time zone info (in bold) @ end of datetime object?

combined date , time in utc(according iso 8601): 2017-07-29t12:48:20+00:00

install , import python-dateutil. make sure convert time stamp datetime (divide stamp 1e3 if longer 10 characters) , use dateutil package add time zone info @ end tzoffset so:

time = datetime.datetime.fromtimestamp(timestamp / 1e3).replace(tzinfo=tzoffset(none, timezone)) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -