Date and time, date and time

Source: Internet
Author: User
Tags month name

Date and time, date and time
# In code, we often need to deal with time. In Python, time processing-related modules include time, datetime, and calendar. # in Python, time is usually expressed using timestamps, formatted time strings, and metadata 3. The following sections describe each other. 1. timestamp # generally, timestamp indicates the offset calculated in seconds starting from, January 1, January 1, 1970, that is, the total number of milliseconds since, January 1, January 01, 1970 (, January 1, January 01, 1970, Beijing time. # Timestamp is an encrypted certificate document, which consists of three parts: ①: The digest of the file to be timestamped (digest ). ②: Date and time when DTS receives the file. ③: Digital Signature of DTS. # Generally, the process of Timestamp generation is as follows: the user first encrypts the file that requires timestamp with Hash encoding to form a digest, and then sends the Digest to DTS, data transmission encrypts the file (digital signature) and sends it back to the user after adding the date and time information of the file digest received. # The time for signing a document in writing is written by the signatory, and the digital timestamp is added by the earnest unit DTS, based on the time when DTS receives the file. # The maximum timestamp supported in Python3.5 is 32535244799 (3001-01-01 15:59:59 ). 2. Time Format symbol # in Python, the time is usually formatted using the format symbol shown in the following table.

Format Description Remarks
% Simplified local week name  
% Local full week name  
% B Simplified local month name  
% B Local full month name  
% C Local Date and Time Representation  
% D The day of the month (01-31)  
% H The hour of the day (in 24-hour format, 00-23)  
% I Hour (in 12-hour format, 01-12)  
% J Day of the year (001-366)  
% M Month (01-12)  
% M Minutes (00-59)  
% P The identifier of the local AM or PM.
% S Seconds (01-61)
% U The number of weeks in a year (value: 00-53, and Sunday is the beginning of a week ).
% W The day of a week (0-6, 0 is Sunday)
% W It is basically the same as % U. The difference is that % W starts from Monday as a week.  
% X Local date  
% X Local time  
% Y Remove the year of the century (00-99)  
% Y Complete year  
% Z Name of the time zone (if it does not exist, it is a null character)  
% % Characters  
# The following describes the meanings of the three remarks in the table ①: % p is effective only when used with % I. ②: The emphasis in this document is indeed 0-61, rather than 59. The leap second takes two seconds. ③: When the strptie () function is used, % U and % W are calculated only when the number of weeks and days of the year are determined. 3. struct_time tuples # struct_time tuples have nine elements: year, month, day, hour, minute, second, the week of the year, the day of the year, whether it is the hour. # The time when a Python function uses a nine-character processing time that is assembled by a single element, also known as struct_time tuples. The following table lists the attributes of this structure.
Serial number Attribute Field Value
0 Tm_year Four years For example, 2008
1 Tm_moon Month 1-12
2 Tm_mday Day 1-31
3 Tm_hour Hours 0-23
4 Tm_min Minutes 0-59
5 Tm_sec Seconds 0-61 (60 or 61 is a leap second)
6 Tm_wday The day of the week 0-6 (0 is Monday)
7 Tm_yday Day of the year 1-366 (Confucianism)
8 Tm_isdst Daylight Saving Time -1, 0, 1,-1 is the flag that determines whether to set the position when the cursor is set.

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.