System.Windows.Forms.DateTimePicker.CustomFormat Property

Gets or sets the custom date/time format string.

Syntax

[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)]
[System.ComponentModel.DefaultValue(null)]
[System.ComponentModel.Localizable(true)]
public string CustomFormat { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

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 DateTimePicker.CustomFormat 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.

Note:

The DateTimePicker.Format property must be set to DateTimePickerFormat.Custom for this property to affect the formatting of the displayed date and time.

The following table lists all the valid format strings and their descriptions.

d

The one- or two-digit day.

dd

The two-digit day. Single-digit day values are preceded by a 0.

ddd

The three-character day-of-week abbreviation.

dddd

The full day-of-week name.

h

The one- or two-digit hour in 12-hour format.

hh

The two-digit hour in 12-hour format. Single digit values are preceded by a 0.

H

The one- or two-digit hour in 24-hour format.

HH

The two-digit hour in 24-hour format. Single digit values are preceded by a 0.

m

The one- or two-digit minute.

mm

The two-digit minute. Single digit values are preceded by a 0.

M

The one- or two-digit month number.

MM

The two-digit month number. Single digit values are preceded by a 0.

MMM

The three-character month abbreviation.

MMMM

The full month name.

s

The one- or two-digit seconds.

ss

The two-digit seconds. Single digit values are preceded by a 0.

t

The one-letter A.M./P.M. abbreviation (A.M. is displayed as "A").

tt

The two-letter A.M./P.M. abbreviation (A.M. is displayed as "AM").

y

The one-digit year (2001 is displayed as "1").

yy

The last two digits of the year (2001 is displayed as "01").

yyyy

The full year (2001 is displayed as "2001").

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0