Python Date and time

Source: Internet
Author: User
Tags month name

Python date operation:

>>> Import time>>> Print time.localtime () #strcy_time元组time. Struct_time (tm_year=2017, TM_MON=12, TM _mday=30, tm_hour=15, tm_min=26, tm_sec=47, tm_wday=5, tm_yday=364, tm_isdst=0) >>> print time.strftime ("%Y-% m-%d%h:%m:%s ", Time.localtime ()) 2017-12-30 15:27:49>>> print time.strftime ("%z:%y-%m-%d%H:%M:%S ", Time.localtime ()) Eastern Standard Time: 2017-12-30 15:27:55

Python time-date formatting symbols:
   %y Two-digit year representation (00-99)
   %y Four-digit year representation (000-9999)
   %m Month (01-12)
   %d months of the day (0-31)
   %H 24-hour hours (0-23)
   %I 12-hour hours (01-12)
   %M minutes (00=59)
   %s seconds (00-59)
   %a Local Simplified week name
   %A Local full week name
   %b Local simplified month name
   %b Local full month name
   %c Local corresponding date representation and time represents
   %j year of the Day (001-366)
   %p The equivalent of a local a.m. or P.M.
   %u Week of the Year (00-53) Sunday is the beginning of the week
   %w Week (0-6), Sunday is the beginning of the week
   %W Week of the Year (00-53) Monday is the beginning of the week
   %x Local corresponding date representation
   %x Local corresponding time representation
   %Z The name of the current time zone
    percent% itself

Serial Number Properties value
0 Tm_year 2008
1 Tm_mon 1 to 12
2 Tm_mday 1 to 31
3 Tm_hour 0 to 23
4 Tm_min 0 to 59
5 Tm_sec 0 to 61 (60 or 61 is a leap second)
6 Tm_wday 0 to 6 (0 is Monday)
7 Tm_yday 1 to 366 (Julian calendar)
8 Tm_isdst -1, 0, 1,-1 is the flag that decides whether to be daylight saving time

Python Date and time

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.