C# Remove UtcOffset from DateTime : DateTime contains UTC format informations.

To remove UTC informations we need to create an instance of DateTime using its Ticks property.

For example:

// DateTime that contains UTC info
DateTime date = DateTime.Now;
date.ToString("o"); // Output "2018-12-07T15:58:01.4217891+01:00" // DateTime without UTC info
date = new DateTime(date.Ticks);
date.ToString("o"); // Output "2018-12-07T15:58:01.4217891"
Tagged:

Laisser un commentaire