Skip to content

Instantly share code, notes, and snippets.

@wholroyd
Created May 27, 2016 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wholroyd/61df669833aed451a3386b478bcc322c to your computer and use it in GitHub Desktop.
Save wholroyd/61df669833aed451a3386b478bcc322c to your computer and use it in GitHub Desktop.
Keep the timezone as an offset and not an adjustment
var test = "2016-11-21T23:00:00-05:00";
var temp1 = DateTime.Parse(test);
temp1.Dump(); // Returns: 11/22/2016 4:00:00 AM
var temp2 = DateTimeOffset.Parse(test);
temp2.Dump(); // Returns: 11/21/2016 11:00:00 PM -05:00
var temp3 = DateTimeOffset.Parse(test).DateTime;
temp3.Dump(); // Returns: 11/21/2016 11:00:00 PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment