Link to home
Start Free TrialLog in
Avatar of CDFx
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!
Avatar of Ramuncikas
Ramuncikas
Flag of Lithuania image

Avatar of CDFx
CDFx

ASKER

Thanks Ramuncikas, but I don't think they'll help me in this situation.
Avatar of OMC2000
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.
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.
Avatar of CDFx

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
Avatar of kodiakbear
kodiakbear

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial