-1

I have some unit test code failing from colleagues from FR. I suspect the issue is related to some datetime formats but I'm not sure what the source is. I have a variable dt that doesn't parse the way I think it should. Below is some output from my Immediate Window

dt
"2016-12-14T00:00:00Z"
DateTime.Parse(dt, CultureInfo.InvariantCulture)
{12/13/2016 7:00:00 PM}
    Date: {12/13/2016 12:00:00 AM}
    Day: 13
    DayOfWeek: Tuesday
    DayOfYear: 348
    Hour: 19
    Kind: Local
    Millisecond: 0
    Minute: 0
    Month: 12
    Second: 0
    Ticks: 636172524000000000
    TimeOfDay: {19:00:00}
    Year: 2016

dt has the value that I think it should, looks to be Dec 14 2016 at midnight. But when I parse it I get Dec 13 at 7 PM. Which I find confusing.

sedavidw
  • 11,116
  • 13
  • 61
  • 95

1 Answers1

1

according to this page

When "Z" (Zulu) is tacked on the end of a time, it indicates that that time is UTC.

  • use DateTimeOffset.Parse(string).UtcDateTime.
afshar
  • 523
  • 4
  • 16