Today in this article, we'll talk about the date and time in Python, and maybe how to get it in Python for a friend who just started learning Python's programming language.
python current timestamp,Let you know how to use
Python Gets the current timestamp.
The Python program can handle dates and times in many ways, and converting date formats is a common feature.
Python provides a time and calendar module that can be used to format dates and times.
The time interval is a floating-point decimal in seconds.
Each timestamp is represented by how long it has been since midnight on January 1, 1970 (the calendar).
There are many functions under the time module of Python to convert common date formats. such as the function Time.time () is used to get the Python timestamp, as in the following example:
#!/usr/bin/python#-*-coding:utf-8-*-import time; # introduce time module ticks = time.time () print "Current timestamp is:", ticks
The results shown in the above example are as follows:
The current timestamp is: 1534234614.98
(timestamp units are best suited for date operations.) But the dates before 1970 cannot be expressed in this way. Too far away from the date, UNIX and Windows only support to 2038 years. )
In this article, we learned how to get the current timestamp in Python, and I used an instance to demonstrate how to get the current timestamp, and I hope this article will help you to learn python.
For more information, please visit the PHP Chinese Web Python tutorial section.