Format datetimepicker date

Source: Internet
Author: User
Tags month name

In datetimepicker, select format as cutstom, and then write the format string in cutstomformat. The introduction is as follows:

How do you display am? It is written as: hh: Mm TT (case sensitive)
To display a string or format string containing the date and time delimiters, you must use an escape character in the substring. For example, to display the date as "June 06 at PM", set the customformat attribute to "Mmmm dd' at 't: Mm TT ". If the escape character does not contain the "at" substring, the result is "June 06 ap pm ", because the character "T" is read as a single letter AM/PM Format String (see Format 1 below) string table ).
Format String that can be combined to set the date and time format. For example, to display the date and time as PM on 06/01/2001, set this attribute to "dd'/'mm'/'yyyy hh': 'Mm TT ". For more information, see date and time format strings.
Note that the format attribute must be set to datetimepickerformat. Custom to affect the format of the displayed date/time.
The following table lists all valid format strings and their descriptions.
Format String description
D. The number of days in one or two digits.
DD. Add zero to the front of the number of days in one digit.
The abbreviation of the day of the week in DDD.
The complete day of the week name of dddd.
One-digit or two-digit hours in H12 hour format.
Two-digit hours in hh12 hour format. Add a zero value before a single-digit value.
One-digit or two-digit hours in h24 hour format.
Two-digit hours in hh24 hour format. Add a zero value before a single-digit value.
M is a one-digit or two-digit minute value.
MM two-digit minute value. Add a zero value before a single-digit value.
M is the one-digit or two-digit month value.
MM two-digit month value. Add a zero value before a single-digit value.
The abbreviation of a month in the mmm format.
The complete month name of Mmmm.
S one-digit or two-digit seconds.
SS two-digit seconds. Add a zero value before a single-digit value.
T the abbreviation of an AM/PM ("am" is displayed as "").
The abbreviation of AM/PM in TT ("am" is displayed as "am ").
Y indicates the year of a single digit (2001 is displayed as "1 ").
The last two digits of the year YY (2001 is displayed as "01 ").
Yyyy complete year (2001 is displayed as "2001 ").

Example
[Visual Basic, C #] the following example sets the customformat attribute so that datetimepicker displays the date as "June 01,200 1-Friday" (Friday, January 1, June 1, 2001 ). This Code assumes that the instance of the datetimepicker control has been created on the form.
[Visual Basic]
Public sub setmycustomformat ()
'Set the format type and the customformat string.
Datetimepicker1.format = datetimepickerformat. Custom
Datetimepicker1.customformat = "Mmmm DD, yyyy-dddd"
End sub 'setmycustomformat
[C #]
Public void setmycustomformat ()
{
// Set the format type and the customformat string.
Datetimepicker1.format = datetimepickerformat. custom;
Datetimepicker1.customformat = "Mmmm DD, yyyy-dddd ";
}

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.