Is there any function in python similar to new Date().getTime() in javascript? I want to get timestamp like this:
1569046436.991
-
Near-duplicate: How to get the current time in PythonAran-Fey– Aran-Fey2019-09-21 06:29:10 +00:00Commented Sep 21, 2019 at 6:29
-
Possible duplicate of How to get the current time in PythonGiftZwergrapper– GiftZwergrapper2019-09-27 13:29:15 +00:00Commented Sep 27, 2019 at 13:29
Add a comment
|
2 Answers
You can either use datetime.timestamp()
from datetime import datetime
print(datetime.now().timestamp())
>> 1569054370.358652
or time.time()
import time
print(time.time())
>> 1569054370.359672