HOW TO CHANGE DEFAULT TIMEZONE C#

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C#  .NET  Time 
 1334  View(s)
Ratings:
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...

  1. Samuel Fernandes

    Post:159

    Points:1117
    Re: How to change default timezone c#

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!