In Python 2 how to convert 10 digit timestamp to 13 digit timestamp?
Input:
today = datetime.now()
yesterday = datetime.now() - timedelta(days=1)
today_unixtime = int((mod_time.mktime(today.timetuple())+today.microsecond/1000000.0))
dt_object = datetime.fromtimestamp(today_unixtime)
print(today)
print("timestamp =", today_unixtime)
print("date =", dt_object)
Output:
2020-01-17 11:31:40.450943
('timestamp =', 1579240900)
('date =', datetime.datetime(2020, 1, 17, 11, 31, 40))
I am getting correct date and time. But when I checked in Chrome browser console,
new Date(1579240900)
it's given me 50 years back date. While I am converting same timestamp in Python:
Input:
dt_object = datetime.fromtimestamp(today_unixtime)
Output:
Mon Jan 19 1970 12:10:40 GMT+0530 (India Standard Time)
Timestamp has to be always 13 digit in year of 2020. Why it's coming as 10 digit? How to convert as 13 digit in Python 2?
I need 13 digit only, my API is taking 13 digit.
This question also asked python convert 10 digits datetimestamp to 13 digit GMT timestamp but no answers.