Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dateime Parse method adding one day to input date

I am reading a date from an xml file and parsing it to a my desired format. It i adding a day to the date and i cant seem to figure out why.

input : 2014-02-12T15:21:19-08:00 output : 13 Feb 2014 01:21

Here is my code to parse date:

string date = DateTime.Parse(row["CountDate"].ToString()).ToString("dd MMM yyyy HH:mm");

Any help will be greatly appreciated.

like image 243
Lucky Luke2 Avatar asked May 30 '26 20:05

Lucky Luke2


1 Answers

The reason is that the timezone information is being used to adjust the time to your local time zone.

If you remove the "-08:00" suffix, you'll find that the time won't be adjusted. However, you need to know whether the timezone information is important before ignoring it!

like image 100
Matthew Watson Avatar answered Jun 02 '26 10:06

Matthew Watson