Time delay/lapse when adding days to a time value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I do the following:

DateTime dt = DateTime.Today.AddDays(0); // that's a zero

then on my machine, the DateTime.ToString("yyyy-MM-dd") returns a date that
is YESTERDAY!

Thinking that I'd be clever, I then did the following:

DateTime dt = DateTime.Today.AddDays(1); // yup, one day

this resulted in the ToString("yyyy-MM-dd") being 2 DAYS in the past!

I checked my timezone settings on the computer, and they all show the
correct time. Any ideas??

Thanks

-- Jake
 
javatopia said:
Hello,

I do the following:

DateTime dt = DateTime.Today.AddDays(0); // that's a zero

then on my machine, the DateTime.ToString("yyyy-MM-dd") returns a date that
is YESTERDAY!

Thinking that I'd be clever, I then did the following:

DateTime dt = DateTime.Today.AddDays(1); // yup, one day

this resulted in the ToString("yyyy-MM-dd") being 2 DAYS in the past!

I checked my timezone settings on the computer, and they all show the
correct time. Any ideas??

Nope, no ideas.

Post a small, *complete* console program that shows the problem (per Jon
Skeet: http://www.yoda.arachsys.com/csharp/complete.html).
 
Back
Top