c# convert date to iso 8601 code example
Example 1: iso date format c#
var newTime = theTime.UtcNow.ToString("o");
// returns "2017-06-26T00:00:00.0000000Z"
var newTime2 = theTime.Date.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.sssZ");
// returns "2017-06-26T00:00:00.00Z"
Example 2: how to convert date to Complete ISO-8601 date in c#
string isoFormatDateString = dateTimeObject.ToUniversalTime().ToString("s") + "Z";
Example 3: c# datetime iso 8601 format
var newTime = theTime.Date.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
// returns "2017-06-26T00:00:00.000Z"