• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

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!
0
CDFx
Asked:
CDFx
1 Solution
 
CDFxAuthor Commented:
Thanks Ramuncikas, but I don't think they'll help me in this situation.
0
 
OMC2000Commented:
The only problem here is that Daylight Savings Time starts and stops at different dates.

check answer based on the database table at
http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20103151.htm

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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
OMC2000Commented:
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.
0
 
CDFxAuthor Commented:
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
0
 
OMC2000Commented:
Ok, fine, "close it and refund" points.
0
 
kodiakbearCommented:
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now