Date Strange format

Hy all

I got dates from an API like this, what is this?

What I kind of format is this? How can I convert it?

Thanks

2020-06-09T14:36:52.9470000Z
2020-06-09T15:45:40.0430000Z
2020-06-09T15:45:48.3100000Z
2020-06-09T15:05:55.4130000Z
2020-06-09T15:43:30.1230000Z
2020-06-09T15:08:32.2200000Z
2020-06-09T16:25:49.3330000Z
2020-06-09T14:45:58.8270000Z
2020-06-09T14:46:06.1530000Z
2020-06-09T14:46:18.5830000Z
2020-06-09T15:43:45.2970000Z
2020-06-09T14:46:38.8670000Z
2020-06-09T15:00:33.6100000Z
2020-06-09T14:47:02.4830000Z

yyyy-MM-ddTHH:mm:ss.fffffffZ

Not sure what the format’s called, but that’s what it’s telling you (year, month, day, hour, minute, second, 10 millionths of a second).

More on format notation here:

1 Like

If you need to convert it to a datetime, set a datetime variable to Datetime.ParseExact(MyVar.Replace("T", String.Empty).Replace("Z", String.Empty), "yyyy-MM-ddHH:mm:ss.fffffff", System.Globalization.CultureInfo.InvariantCulture), where MyVar is the string representation of the times you show above.

3 Likes

@Anthony_Humphries,

Thank you very much!! This format is just crazy!

IT Seems to have IT a relationship to some ISO Standards. I saw this Sometimes when I worked with Rest Apis
https://www.w3.org/TR/NOTE-datetime-970915

You’re not accustomed to this format but it is quite convenient for at least two reasons:

  • it is easy to sort
  • it is timezone aware.

and an extra one:

it’s human readable :slight_smile:

You can produce it with myDateTime.ToString("o")

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.