Python date Time object converted to string __python

Source: Internet
Author: User
Python date Time object converted to string 1, standard conversion format symbol Description
%a Local week short name such as: Sun, Mon, ..., Sat (en_US); So, Mo, ..., Sa (De_de)
%A Local week full name such as: Sunday, Monday, ..., Saturday (en_US); Sonntag, Montag, ..., Samstag (De_de)
The number of%w weeks indicates that 0 represents Sunday, 6 indicates Saturday such as: 0,1,2,,,6
The number of%d days is indicated and the use of 0来 fills (0-9), such as: 01, 02, ..., 31
%b month short name display, English word shorthand, such as: The Long, Feb, ..., Dec (en_US); Feb, Dez (DE_DE)
%B Month Full name display, such as: January, February, ..., December (en_US); Januar, Februar, ..., Dezember (De_de)
%m month digital display, and with 0来 complement, such as: 01, 02, ..., 12
%y the number of years indicated that two digits, such as: 00, 01, ..., 99
The number of%Y years indicates that four-bit representations, such as: 0001, 0002, ..., 2013, 2014, ..., 9998, 9999
%H 24-hour system, such as: 00, 01, ..., 23
%I 12-hour system, such as: 01, 02, ..., 12
%p on the afternoon, such as: am,pm
%m minutes, and with 0 complement (0-9), such as: 00, 01, ..., 59
%s seconds, and with 0 full complement (0-9), such as: 00, 01, ..., 59
%f subtle representations, such as: 000000, 000001, ..., 999999
%z time zone offsets, such as: (empty), +0000,-0400, +1030
%Z time zone name, such as: (empty), UTC, EST, CST
%j which of the year, with 0 complement, such as: 001, 002, ..., 366
%u in the first few weeks of the year, Sunday for day one: 00, 01, ..., 53
%w Week of the year, Monday for the first day such as: 00, 01, ..., 53
%c local time, such as: 06/24/17 15:43:10
%x local date, such as: 08/16/88 (None);
%x local time, such as: 21:30:00 (en_US);
%%% symbol 2. Python Date function ConversionDisplay current time as: 2017-06-24 10:10:20 form
>>> from datetime import datetime
>>>now = DateTime.Now ()
>>>
Now Datetime.datetime (2017, 6, 511223)
>>> strnow = Datetime.strftime (now, '%y-%m-%d%h:%m:%s ') c5/>>>> strnow
' 2017-06-24 16:12:16 '
Add the last afternoon logo
>>> Strnow = Datetime.strftime (now, '%y-%m-%d%h:%m:%s%p ')
>>> strnow
' 2017-06-24 16:12:16 PM '
Output current date is the day of the year, the first few weeks
>>> Strnow = Datetime.strftime (now, '%y-%m-%d%h:%m:%s%p%u%j ') 
>>> strnow
' 2017-06-24 16:12:16 PM 25 175 '



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.