python time formatting

巴扎黑
Release: 2016-12-09 11:15:30
Original
1448 people have browsed it

The operation of function strftime() is somewhat similar to sprintf(): it identifies a set of format commands starting with a percent sign (%), and the formatted output results are placed in a string. The formatting command specifies the exact representation of various date and time information in the string strDest. The other characters in the format string are put into the string as they are. The format commands are listed below and are case-sensitive.

%a The abbreviation of the day of the week
%A The full name of the day of the week
%b The abbreviation of the month
%B The full name of the month
%c The standard date time string
%C The last two digits of the year
%d Decimal The day of the month represented by
%D month/day/year
%e In the two-character field, the day of the month represented by decimal
%F year-month-day
%g The last two digits of the year Number, use week-based year
%G Year minute, use week-based year
%h Abbreviated month name
%H Hour in 24-hour format
%I Hour in 12-hour format
%j Number of the year in decimal notation Days
%m Month expressed in decimal system
%M Minutes expressed in ten-hour system
%n Newline character
%p Local AM or PM equivalent display
%r 12-hour time
%R Display hour and sum Minutes: hh:mm
%S Decimal seconds
%t Horizontal tab character
%T Display hours, minutes and seconds: hh:mm:ss
%u Day of the week, Monday is the first day (value starts from 0 to 6, Monday is 0)
%U The week number of the year, using Sunday as the first day (values ​​from 0 to 53)
%V The week number of the year, using the week-based year
%w The day of the week in decimal notation (values ​​range from 0 to 6, Sunday is 0)
%W The number of weeks of the year, with Monday as the first day (values ​​range from 0 to 53)
%x Standard date string
%X Standard time string
%y Decimal year without century (value from 0 to 99)
%Y Decimal year with century part
%z, %Z time zone name, if the time zone name cannot be obtained, a null character is returned.
%% percent sign


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template