My legacy javascript code is below.
let today = new Date(Date.now());
let todayStr = today.getFullYear() + '-' + addZero(today.getMonth()+1) + '-' + addZero(today.getDate());
let todayStart = (new Date(todayStr + ' 00:00:00')).valueOf()
console.log(todayStart)
It's result is 1544454000000
. That is my server's valid input format.
So I want to migrate this code to Python. My trial was that use datetime.fromtimestamp
.
But result was not same to javascript's.
Thanks in advance.
Python doesn't use milliseconds like JavaScript - it uses seconds. So 1000
in JavaScript would be 1
in Python. So all you have to do is:
int(datetime.fromtimestamp) * 1000
To fix the language difference.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.