How is python timestamp obtained? How do I get the current timestamp?

Source: Internet
Author: User
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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.