UniversalSortableDateTimePattern Property

DateTimeFormatInfo.UniversalSortableDateTimePattern Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the custom date and time format string for a universal sortable date and time value, which is associated with the "u" standard format string.

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

public string UniversalSortableDateTimePattern { get; }

Property Value

Type: System.String
The custom format string for a universal sortable date and time value, which is associated with the "u" standard format string.

UniversalSortableDateTimePattern can be used to display time in a sortable format with the universal time designator "Z" at the end. The format is sortable because it uses leading zeros for year, month, day, hour, minute, and second. The string ("yyyy'-'MM'-'dd HH':'mm':'ss'Z'") is the same regardless of culture or format provider.

The following example displays the value of UniversalSortableDateTimePattern for a few cultures.


using System;
using System.Globalization;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Displays the values of the pattern properties.
      outputBlock.Text += " CULTURE    PROPERTY VALUE" + "\n";
      PrintPattern(outputBlock, "en-US");
      PrintPattern(outputBlock, "ja-JP");
      PrintPattern(outputBlock, "fr-FR");
   }

   public static void PrintPattern(System.Windows.Controls.TextBlock outputBlock, String myCulture)
   {
      DateTimeFormatInfo myDTFI = new CultureInfo(myCulture).DateTimeFormat;
      outputBlock.Text += String.Format("  {0}     {1}", myCulture, myDTFI.UniversalSortableDateTimePattern) + "\n";
   }
}
/*
This example produces the following output.
    CULTURE    PROPERTY VALUE
     en-US     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
     ja-JP     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
     fr-FR     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
*/


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2016 Microsoft