Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return current 11-digit timestamp in Python

Tags:

How can I return the current time of the local machine?

like image 293
ensnare Avatar asked Mar 29 '10 17:03

ensnare


People also ask

How do you find the 13 digit timestamp in Python?

now() is used to get the present time. The timetuple() is a method of datetime class that returns the attributes of datetime as a name tuple. To get the timestamp of 13 digits it has to be multiplied by 1000.

How do I return a timestamp in Python?

We can convert the timestamp back to datetime object using the fromtimestamp() method that is available in the datetime module. It returns the local date and time corresponding to the POSIX timestamp, such as is returned by time. time() .

How do I get the exact timestamp in Python?

To get the current time in particular, you can use the strftime() method and pass into it the string ”%H:%M:%S” representing hours, minutes, and seconds.

How do I get the current UTC timestamp in Python?

Getting the UTC timestampUse the datetime. datetime. now() to get the current date and time. Then use tzinfo class to convert our datetime to UTC.


1 Answers

Do you mean this: time.time()?

From the docs:

Return the time as a floating point number expressed in seconds since the epoch, in UTC

>>> import time
>>> time.time()
1269884900.480978
>>> 
like image 61
ChristopheD Avatar answered Oct 10 '22 09:10

ChristopheD