Difference between UniversalSortableDateTimePattern and SortableDateTimePattern

UniversalSortableDateTimePattern uses UTC. That's what the Z at the end is for.

Try this simple sample:

string s = DateTime.Now.ToString(CultureInfo.CurrentCulture.DateTimeFormat.SortableDateTimePattern);
DateTime d = DateTime.Parse(s);

Console.WriteLine(s);
Console.WriteLine(d);

Console.WriteLine();

s = DateTime.Now.ToString(CultureInfo.CurrentCulture.DateTimeFormat.UniversalSortableDateTimePattern);
d = DateTime.Parse(s);

Console.WriteLine(s);
Console.WriteLine(d);

So long as your timezone is not UTC+0, you'll notice the time is different on the second block.

My read on this would be to prefer UniversalSortableDateTimePattern when used across timezones.

Tags:

C#