Changing time from epoch time to iso format in Python -
this question has answer here:
i change time epoch time format readable kml extensions (such iso format of time).
there plenty of change epoch formats yyyymmddhhmmss , other structs using tuples , mktime, .iso formation , haven't been able find it.
utcfromtimestamp converts seconds since epoch corresponding utc datetime.datetime.
datetime.datetime
objects have isoformat
method returns date string in iso 8601 format.
in [6]: import datetime dt in [7]: seconds_since_epoch = 0 in [8]: dt.datetime.utcfromtimestamp(seconds_since_epoch) out[8]: datetime.datetime(1970, 1, 1, 0, 0) in [9]: dt.datetime.utcfromtimestamp(seconds_since_epoch).isoformat() out[9]: '1970-01-01t00:00:00'
Comments
Post a Comment