c# .net

How to change datetimeoffset to datetime c# ?

How to change datetimeoffset to datetime c# ?, someone asked me to explain?

In this tutorial I will show you how to convert datetimeoffset to datetime using c#. Here, I want to save the datetime object value into the database. But the datetimeoffset was returning string value. In order to convert string (datetimeoffset) to datetime you may follow this way,

datetimeoffset to datetime c#

DateTimeOffset newTime = TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));

invoice.CreatedOn = newTime.DateTime;

 

Post your comments / questions