Now I want to transfer timstamp() in Python into timstamp() in JS. But the problem is Python uses seconds, while JS uses milliseconds. How can I transfer Python's version into JS? For example:
For Python
python_stamp = int(time.mktime(time.gmtime()))
then the output is
python_stamp=1481269558
But for JS:
JS_timestamp = Date().getTime()
then the output is
JS_timestamp = 1481269558356
Do you know how to transfer Python's version into JS. By the way, please do not say python_stamp*1000, basically, it is not a solution I want to find.
here are a couple of examples to get milliseconds
from datetime import datetime
print(int(datetime.now().strftime("%s%f")) / 1000)
example 2
from time import time
print(time()) # 1481253947.930211
print(int(time() * 1000)) # 1481253947930
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With