Python Convert 10 Digits Datetimestamp To 13 Digit Gmt Timestamp
I receive a timestamp from a server like this 1512543958 & when i send back requests in headers i see a 13 digit GMT time stamp like this 1512544485819 By changing the time to
Solution 1:
I am using python 2.7
import time
import datetime
import time as mod_time
from datetime import datetime
from datetime import datetime, timedelta
from datetime import date, timedelta
today = datetime.now()
yesterday = datetime.now() - timedelta(days=1)
today_time = int((mod_time.mktime(today.timetuple())))
yesterday_time = int((mod_time.mktime(yesterday.timetuple())))
today_unixtime = (today_time*1000)
yesterday_unixtime = (yesterday_time*1000)
print("today timestamp =", today_unixtime)
print("yesterday timestamp =", yesterday_unixtime)
Output
('today timestamp =', 1579243097000)
('yesterday timestamp =', 1579156697000)
You can check the current time stamp from crome browser console.
new Date(1579243097000)
it will gives you a current date and time.
Post a Comment for "Python Convert 10 Digits Datetimestamp To 13 Digit Gmt Timestamp"