Hello, I would like to know how can I convert UTC datetime into local (user's pc) datetime in asp.net MVC razor page using C#?
I thought .ToLocalTime() should work, but I am not getting correct result.
Here are the possible methods to convert UTC time into Local using C#
DateTime.ParseExact(dateString, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)
In the above code, we have considered that Datetime format is known to us
Any of the above ways should work.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly