Sitecore 8 - Date issue

Jul 3, 2015 Posted by Lara Kannan
In Sitecore 8, my due date column has the value like 2015-07-03 00:00:00. This date was displayed in UI as 2015-07-02 22:00:00+2.

The issue arises, because Sitecore have implemented a feature that tries to handle local time zones on the server. Old Sitecore 7.5 dates are stored without any timezone information

  • 20150412T000000
In Sitecore 8, Sitecore have changed the raw data format of the date field by taking the timezone into consideration. Which in my case means that my 2014-04-12 00:00:00 becomes 2015-04-11 22:00:00

  • 20150411T220000Z
Notice the “Z” at the end? This implies that this is a datetime that have a timezone, and the timezone is now 2 hours behind UTC.

To fix the old datetime fields, I need to tell Sitecore which timezone non-timezone-datetime fields have. This is the setting, ServerTimeZone:

<setting name="ServerTimeZone" value="UTC" />

I also needed to update the Lucene index, as the invalid datetime was added to the index as well.

Thanks to Peter Wind who helped find this issue.

Or else, use below method:
 DateTime dateShow = Sitecore.DateUtil.IsoDateToDateTime(showDate);        
 DateTime localDate = TimeZone.CurrentTimeZone.ToLocalTime(dateShow);   



Post a Comment