Last post Jul 19, 2018 01:02 PM by Brando ZWZ
Jul 18, 2018 05:22 AM|nambir|LINK
My Project is a appointment project where the user will pick the time slot and book it.
Things were fine running fine in localhost, when i host in the azure server, date time stored is different than my local zone (Malaysian time). So the time stored was in US time.
How to handle this scenario?
when i pick the date and time how to make sure that time selected is in Malaysian time and stored as malaysian time, irrespective of where the server is.
Jul 18, 2018 05:34 AM|vahid bakkhi|LINK
you can convert the server time zone to your time zone
var serverTime = DateTime.Now;
var serverZone = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time");
var localZone = TimeZoneInfo.FindSystemTimeZoneById("Malay Peninsula Standard Time"); var localTime = TimeZoneInfo.ConvertTime(serverTime, serverZone, localZone);
Malay Peninsula Standard Time
note: just be sure about the correct name for time zones
Jul 19, 2018 01:02 PM|Brando ZWZ|LINK
If you use azure web app, we could change the server time zone .
You could add an application setting (using the portal) called “WEBSITE_TIME_ZONE” equal to the name of the time zone in question (basically the same string as the key name at HKLM\Software\Microsoft\Windows Nt\CurrentVersion\Time Zones\).
If you use azure VM, it is not recommended you try to change the Time Zone, you should rather use methods like TimeZoneInfo.ConvertTimefromUTCTime in your code (.Net).
More details, you could refer to below article: