How to perform DateTime calculations in a right way(dotnettipoftheday.org)

submitted by SirkoSirko(105) 4 years, 8 months ago

When coding, be careful if you need to perform DateTime calculations (add/subtract) on values representing time zones that practice daylight savings time.

2 comments |category: |Views: 12

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by dmihailescudmihailescu(25) 4 years, 7 months ago 0

DateTime d;

d = DateTime.Parse("Oct 26, 2003 12:00:00 AM"); //date assignment

d = d.ToUniversalTime().AddHours(3.0).ToLocalTime();



//' - displays 10/26/2003 02:00:00 AM – Correct!

MessageBox.Show(d.ToString());
I thought that the correct result should be 3 a.m. not 2.a.m.
Am I missing something?

Reply

posted by manovichmanovich(755) 4 years, 6 months ago 0

Correct result is 2 a.m. because in 2003 daylight savings time ended at 2 a.m. October 26.
http://webexhibits.org/daylightsaving/b.html

Reply

information Login or create an account to comment on this story