How to change time zone for an asp.net application

前端 未结 6 961
一个人的身影
一个人的身影 2020-12-31 03:43

I need to set default timezone for my ASP.NET to Asia/Dhaka or GMT+6 timezone. But i cannot find a way to change it globally. There is a lot of reference on Stackoverflow an

6条回答
  •  無奈伤痛
    2020-12-31 03:47

    You can Change TimeZone...And Get Date

     DateTime utcTime = DateTime.UtcNow;
        TimeZoneInfo myZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
        DateTime custDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, myZone);
        Str.Append(custDateTime.ToString());
    

提交回复
热议问题