C# DateTime Formatting Quick Reference

System.DateTime does not store the time zone information. It only knows if it's local or UTC. Local can be tricky and many server-side libraries will automatically convert the time to UTC before sending it back in a service response. If you're reading a date/time from a database, file, or somewhere else where the time zone is not stored but you know that it is UTC (for instance) use SpecifyKind:

    DateTime.SpecifyKind(dt, DateTimeKind.Utc);

You can then convert it to local time with the ToLocalTime method.

Here are a few formatting strings I use often and have to keep looking up.

To get this Use this More info
2014-12-24T13:17:27.294-08:00 yyyy-MM-ddTHH:mm:ss.fffzzz This is the ISO date format typically used in JavaScript. "zzz" refers to offset from UTC. If this is omitted UTC time is assumed.
December 24, 2014 MMMM dd, yyyy  
1:53:43 PM h:mm:ss tt