Sitecore 8 - Date issue
Jul 3, 2015
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
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:
Thanks!
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
- 20150411T220000Z
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);
Thanks!
Share
Labels:
Site-core