# The Best Culture Invariant Format for DateTime

If you are looking to display how to display DateTime as text without causing confusion to users in different countries then good choices is either “o” or “r”. The “o” format is in general more preferable as it also puts timezone offset.

long t = DateTime.Now.Ticks;
Console.WriteLine((new DateTime(t)).ToString("o"));
Console.WriteLine((new DateTime(t, DateTimeKind.Local)).ToString("o"));
Console.WriteLine((new DateTime(t, DateTimeKind.Unspecified)).ToString("o"));
Console.WriteLine((new DateTime(t, DateTimeKind.Utc)).ToString("o"));


Prints followings when actual date time is 2009-11-08T17:16:13.7791953 PST:

2009-11-08T17:16:13.7791953
2009-11-08T17:16:13.7791953-08:00
2009-11-08T17:16:13.7791953
2009-11-08T17:16:13.7791953Z


If you use “r” instead it would print followings:

Sun, 08 Nov 2009 17:26:02 GMT
Sun, 08 Nov 2009 17:26:02 GMT
Sun, 08 Nov 2009 17:26:02 GMT
Sun, 08 Nov 2009 17:26:02 GMT

##### Shital Shah

A program trying to understand what it’s computing.