All formatted output of datetime

Source: Internet
Author: User

Example: Today, July 22, datetime. Now. tostring ("yyyy-mm-dd") returns "April 24 ".

The following is an SDK from 1.1:

D. display the day as a number without leading zero (for example, 1 ). If this is a unique character in the User-Defined number format, use % d.
Dd displays the day as a number with a leading zero (for example, 01 ).
Ddd displays the day as an abbreviation (for example, Sun ).
Dddd displays the day as the full name (for example, Sunday ).

M Displays the month as a number without leading zero (for example, January 1, January ). If this is a unique character in the User-Defined number format, use % m.
MM displays the month as a number with a leading zero (for example, 01/12/01 ).
Mmm displays the month as an abbreviation (for example, Jan ).
Mmmm displays the month as the complete month name (for example, January ).

Gg display the time/epoch string (for example, A. D .)

H uses the 12-hour system to display the hour as a number without leading zero (for example, 1:15:15 ). If this is a unique character in the User-Defined number format, use % H.
HH uses the 12-hour system to display the hour as a number with a leading zero (for example, 01:15:15 ).
H uses the 24-hour system to display the hour as a number without leading zero (for example, 1:15:15 ). If this is a unique character in the User-Defined number format, use % H.
HH uses the 24-hour system to display the hour as a number with a leading zero (for example, 01:15:15 ).

M Displays the minute as a number without leading zero (for example ). If this is a unique character in the User-Defined number format, use % m.
MM displays the minute as a number with a leading zero (for example, 12:01:15 ).

S displays the second as a number without leading zero (for example ). If this is a unique character in the User-Defined number format, use % S.
SS displays seconds as numbers with leading zeros (for example, 12:15:05 ).

F displays the fractional part of the second. For example, FF is precisely displayed to 1% seconds, while FFFF is precisely displayed to one in ten seconds. Up to seven F characters can be used in a user-defined format. If this is a unique character in the User-Defined number format, use % F.

T uses the 12-hour format, and displays uppercase A for any hour before noon, and uppercase P for any hour between noon and p.m. If this is a unique character in the User-Defined number format, use % T.
TT uses the 12-hour format, and displays the uppercase am for any hour before noon; for any hour between noon and p.m., the uppercase PM is displayed.

Y displays the year (0-9) as a number without leading zero. If this is a unique character in the User-Defined number format, use % Y.
YY displays the year in the format of two digits with leading zeros (if applicable ).
YYY displays the year in four-digit format.
Yyyy displays the year in four-digit format.

Z shows the time zone offset without leading zero (for example,-8 ). If this is a unique character in the User-Defined number format, use % Z.
ZZ displays the time zone offset with the leading zero (for example,-08 ).
ZZZ shows the full time zone offset (for example ).

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.