Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is python3 equivalent of Date.now() of javascript?

In JavaScript, I can assign:

var now = Date.now();

Then use now to calculate as a number variable

>>> import datetime
>>> datetime.datetime.now()
>>> datetime.datetime.today()

In python3, Using upper code doesnt seem helpful. Any idea what is equivalent of Date.now().

like image 403
Machinexa Avatar asked Jan 20 '26 00:01

Machinexa


1 Answers

You should use time module.

>>> import time
>>> int(time.time() * 1000) #for getting the millisecs

1601559393404
like image 157
Equinox Avatar answered Jan 21 '26 14:01

Equinox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!