This article mainly introduces the datetime module in the python time module. The interface of the datetime module is more intuitive and easier to call, if you want to know about the datetime module, you can refer to Python to provide multiple built-
Python provides several built-in modules for manipulating date times, like Calendar,time,datetime. Time module I have described in the previous article, it provides the interface and C standard library time.h basically consistent. The interface of
Example of the usage of the time and datetime modules in Python, pythondatetime
Time module method:Time. time (): Get the timestamp of the current time
Time. localtime (): receives a timestamp and converts it to a tuples of the current time. If no
ObjectiveInterpretation of related termsThe manifestation of timeTime ModuleDateTime moduleTime Format CodeSummarizeObjectiveIn the development work, we often need to use the date and time, such as:Content output as log informationCalculate the
Python3 time module and datetime module, python3datetime
Time Module
In Python, these methods are usually used to represent the time: 1) timestamp 2) formatted time string 3) there are nine elements in the tuples (struct_time. Since the time module
This article mainly introduces the usage examples of the time module and datetime module in Python. it mainly demonstrates the printing and calculation of time and date. For more information, see
Time Module method:
Time. time (): Get the
There are three types of time-performance formats in the Times module:
A, timestamp timestamp, which represents the offset calculated in seconds from January 1, 1970 00:00:00
B, struct_time time tuple, a total of nine element groups.
C, format time
JS time stamp into C # time, and then the C # time stamp into JS time
The time stamp in JS
Copy Code code as follows:
var dt = new Date (). GetTime ();//Time stamp
C # time stamp turn time
Copy Code code as follows:
TimeCommon have time.time() and time.sleep() functions.import timeprint(time.time())1499305554.3239055The floating-point number above is called the Unix epoch timestamp, which is the seconds from 0 O'Clock January 1, 1970 to today. you can see that
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.