Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

EZP-29279: Fix value displayed by the Date Field Type being affected by browser time zone #984

Merged
merged 2 commits into from
Dec 18, 2018

Conversation

jacek-foremski
Copy link
Contributor

JIRA ticket: EZP-29279

Currently the value for Date Field Type displayed in the backoffice is affected by the browser's timezone, meaning that if the browser has timezone below (west of) UTC, then the previous day is displayed.
Value stored in the database is always midnight in UTC.
Javascript automatically uses the browser's timezone when handling Date objects, so in this PR I fix the issue by manually adding the offset.

* @return String
*/
_formatDate: function (date) {
return date.toLocaleDateString(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better readable when it looks like this:return date.toLocaleDateString(undefined, {timeZone: 'UTC'});

* @method _formatDate
* @protected
* @param {Date} date
* @return String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return {String}

@jacek-foremski
Copy link
Contributor Author

@sunpietro fixed, thanks.

@jacek-foremski jacek-foremski requested a review from dew326 August 16, 2018 12:37
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Development

Successfully merging this pull request may close these issues.

4 participants