Are you sure this is the correct number? At first I thought it’s an epoch but that resulted in much too big a year; however, taking away the last three 0
s works which makes me wonder if the epoch is in milliseconds instead of seconds (wild hand-wavy assumption):
>>> import time
>>> time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(1539205200000))
'50745-06-22 00:00:00'
>>> time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(1539205200))
'2018-10-10 21:00:00'
or
>>> import datetime
>>> datetime.datetime.fromtimestamp(1539205200000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: year is out of range
>>> datetime.datetime.fromtimestamp(1539205200)
datetime.datetime(2018, 10, 11, 7, 0)
To produce your desired output, just change the format string:
>>> # Assuming constant format "/Date(…)/", this also removes the trailing zeroes..
>>> funky_timestamp = int(o["duedate"][6:-5])
>>> datetime.datetime.fromtimestamp(funky_timestamp).strftime("%d/%m/%Y")
'11/10/2018'