Home > DeveloperSection > Forums > How to change default timezone c#
Manoj Bhatt
Manoj Bhatt

Total Post:154

Posted on    March-10-2015 4:18 AM

 .NET C#  .NET  Time 

 1 Reply(s)
 1215  View(s)
Rate this:

How can I change default timezone on my MVC(c#) web application? Server located in USA, clients connecting from Turkey... I'm looking for a global solution for it, as global.asax or webcofig...

Samuel Fernandes
Samuel Fernandes

Total Post:159

Posted on    March-10-2015 6:41 AM

DateTime utcTime = DateTime.UtcNow;
        string zoneID = CurrentUserSession.TimeZoneID // Here you get the current login user session and their TimeZone which you configured in database at the time of user creation. or if you want to get client pc time zone then you have to use javascript and get client pc Timezone
        TimeZoneInfo myZone = TimeZoneInfo.FindSystemTimeZoneById(zoneID);
        DateTime custDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, myZone);

Modified On Mar-10-2015 06:44:21 AM

Don't want to miss updates? Please click the below button!

Follow MindStick