Thursday, February 23, 2006

.NET String Formatting gotcha

Ok, so I found the problem.

I was using this snippet of code to format the date:

DateCreated.ToString("yyyy-MM-ddThh:mm:ssZ")


What I should have been using was:

DateCreated.ToString("yyyy-MM-ddTHH:mm:ssZ")


Notice the "hh" versus "HH". The small hh gives 12-hour hours, and the large HH gives 24 hour hours. So, 9PM with hh is 09, and 9PM with HH is 21.

Blogger expects the 24-hour time format, so my post showed up as 12 hours earlier than it should have been.

All fixed now, though.

No comments: