DateTimeFormatInfo::TimeSeparator Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the string that separates the components of time, that is, the hour, minutes, and seconds.

Namespace:   System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

property String^ TimeSeparator {
	String^ get();
	void set(String^ value);

Property Value

Type: System::String^

The string that separates the components of time. The default for InvariantInfo is ":".

Exception Condition

The property is being set to null.


The property is being set and the DateTimeFormatInfo object is read-only.

If the custom pattern includes the format pattern ":", DateTime::ToString displays the value of TimeSeparator in place of the ":" in the format pattern.

The time separator is derived from the ShortTimePattern property. We recommend that you set the time separator in short or long time patterns to an exact string instead of using the time separator placeholder. For example, to obtain the pattern h-mm-ss, set the pattern to "h-mm-ss". This practice also enables you to set patterns such as "h'h 'mm'm 'ss's'" (3h 36m 12s) that include multiple types of separators. The TimeSeparator property defines the string that replaces the time separator (":" custom date and time format specifier) in a result string in a formatting operation. It also defines the time separator string in a parsing operation.

The following example instantiates a CultureInfo object for the en-US culture, changes its date separator to ".", and displays a date by using the "t", "T", "F", "f", "G", and "g" standard format strings.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top