<t>Note to readers:<br/>
<br/>
Several commenters have pointed out some problems in this answer (related particularly to the first suggestion). Refer to the comments section for more information.<br/>
<br/>
// Do not use this<br/>
DateTime.UtcNow.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz", CultureInfo.InvariantCulture);<br/>
<br/>
```<br/>
<br/>
Using [custom date-time formatting](https://learn.microsoft.com/dotnet/standard/base-types/custom-date-and-time-format-strings), this gives you a date similar to<br/>
<br/>
**2008-09-22T13:57:31.2311892-04:00**.<br/>
<br/>
Another way is:<br/>
<br/>
```<br/>
// Prefer this, to avoid having to manually define a framework-provided format<br/>
DateTime.UtcNow.ToString("o", CultureInfo.InvariantCulture);<br/>
<br/>
```<br/>
<br/>
which uses the standard ["round-trip" style](https://learn.microsoft.com/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip) (ISO 8601) to give you<br/>
<br/>
**2008-09-22T14:01:54.9571247Z**.<br/>
<br/>
To get the specified format, you can use:<br/>
<br/>
```<br/>
DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)<br/>
<br/>
```</t>