I've got an automated process started that downloads a Feature Layer Collection from an AGOL account for clean-up and rewrite. Comes down just fine as a CSV but the dates come down as a large number that I can convert using float. I'm unable to come across any way to convert this in Python (3.7) to make it a usable DateTime feature. Can you point me towards a way to accomplish this. Neither of the lines of code below do anything with the number.
ndt_value = (datetime.datetime(float(date_value), dateFormat=u'%m/%d/%Y', timeFormat=u'%I:%M:%S %p')
ndt_value = time.strptime(float(date_value), "%d %b %y")
They all come across looking like this.
dte1 dte2
value 1549492620000.0 1549663223992.0
value 1549493100000.0 1549661829963.0
value 1549493220000.0 1554867569006.0
value 1549394280000.0 1554867776915.0
Hi Jackie Fisher,
The date values in your output are epoch timestamps in milliseconds.
The time.ctime()
function takes seconds passed since epoch as an argument and returns a string representing local time. So, you have to divide your values by thousand, like this:
import time
print(time.ctime(1549492620000.0/1000))
# Output will be:
# Wed Feb 06 23:37:00 2019
For a quick, manual conversion of an epoch timestamp you can have a look at this website: https://www.epochconverter.com/
HTH,
Egge-Jan
Thank You. It was just driving me crazy.
Please feel free to mark the answer as correct if your issue is being solved 🙂