I would like to change the time from epoch time to a format readable by Kml extensions (such as iso format of time).
There is plenty of help to change from epoch to formats like YYYYMMDDHHMMSS and other structs using tuples and mktime, but to .iso formation , i haven't been able to find it.
utcfromtimestamp converts seconds since the epoch to the corresponding UTC datetime.datetime.
datetime.datetime
objects have a isoformat
method which returns the date as a string in ISO 8601 format.
In [6]: import datetime as 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'
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