CDFx
asked on
VB.NET - Times based on Daylight Savings
I have written an VB.NET .ashx page that displays the time for Melbourne (VIC), Irvine (California), and Toronto (Canada), but I need to take into account the daylight savings time periods for those cities and adjust the time accordingly, but can't get my head around the code that is needed.
Does anyone have any suggestions on how I should do this?
I'm using the command "DateTime.UtcNow" to get the GMT time.
Thanks!
Does anyone have any suggestions on how I should do this?
I'm using the command "DateTime.UtcNow" to get the GMT time.
Thanks!
ASKER
Thanks Ramuncikas, but I don't think they'll help me in this situation.
The only problem here is that Daylight Savings Time starts and stops at different dates.
check answer based on the database table at
https://www.experts-exchange.com/questions/20103151/Convert-time-to-one-in-different-time-zone-in-PHP.html
or just use general approach, add subtract difference in hours from your time.
Change number of hours depending on current date.
Make functions:
f1, which calculates difference between your time and GMT, you will always get correct difference for your time zone based on OS functionality.
f2, which calculates difference between desired time zone and GMT,
it must take daylignt saving into consideration. If current date is within daylight savings period, function returns 2, otherwise 1.
sum of the results of these two functions is number of hours, which you should subtract from you current time.
check answer based on the database table at
https://www.experts-exchange.com/questions/20103151/Convert-time-to-one-in-different-time-zone-in-PHP.html
or just use general approach, add subtract difference in hours from your time.
Change number of hours depending on current date.
Make functions:
f1, which calculates difference between your time and GMT, you will always get correct difference for your time zone based on OS functionality.
f2, which calculates difference between desired time zone and GMT,
it must take daylignt saving into consideration. If current date is within daylight savings period, function returns 2, otherwise 1.
sum of the results of these two functions is number of hours, which you should subtract from you current time.
It becomes popular to declare that "I solved problem by myself", after the answer, which describes the working solution, was posted.
Well, close it and refund. It's just a reason to check questioner's history first.
Well, close it and refund. It's just a reason to check questioner's history first.
ASKER
Your so-called "working solution" had nothing to do with me solving the problem. I actually found the solution myself using some code from this site: http://www.michaelbrumm.com/simpletimezone.html
Ok, fine, "close it and refund" points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.codeproject.com/dotnet/WorldClock.asp?df=100&forumid=126704&exp=0&select=1411038
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/datetimecode.asp