c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to change datetimeoffset to datetime c# ?

| | ASP-NET , CSharp

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 newTime = TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));

invoice.CreatedOn = newTime.DateTime;