Gets or sets the custom date/time format string.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
To display string literals that contain date and time separators or to format strings, you must use escape characters in the substring. For example, to display the date as "June 15 at 12:00 PM", set the property to "MMMM dd 'at' t:mm tt". If the "at" substring is not enclosed by escape characters, the result is "June 15 aP 12:00PM" because the "t" character is read as the one-letter A.M./P.M. format string (see the format string table below).
The format strings can be combined to format the date and time. For example, to display the date and time as 06/15/2001 12:00 PM, this property should be set to "MM'/'dd'/'yyyy hh':'mm tt". For more information, see Custom Date and Time Format Strings.
The following table lists all the valid format strings and their descriptions.
The one- or two-digit day.
The two-digit day. Single-digit day values are preceded by a 0.
The three-character day-of-week abbreviation.
The full day-of-week name.
The one- or two-digit hour in 12-hour format.
The two-digit hour in 12-hour format. Single digit values are preceded by a 0.
The one- or two-digit hour in 24-hour format.
The two-digit hour in 24-hour format. Single digit values are preceded by a 0.
The one- or two-digit minute.
The two-digit minute. Single digit values are preceded by a 0.
The one- or two-digit month number.
The two-digit month number. Single digit values are preceded by a 0.
The three-character month abbreviation.
The full month name.
The one- or two-digit seconds.
The two-digit seconds. Single digit values are preceded by a 0.
The one-letter A.M./P.M. abbreviation (A.M. is displayed as "A").
The two-letter A.M./P.M. abbreviation (A.M. is displayed as "AM").
The one-digit year (2001 is displayed as "1").
The last two digits of the year (2001 is displayed as "01").
The full year (2001 is displayed as "2001").
The following code example sets the property so that the DateTimePicker will display the date as "June 01, 2001 - Friday". This code assumes that an instance of a DateTimePicker control has been created on a Form.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.