diff --git a/Resources/public/js/views/fields/ez-date-editview.js b/Resources/public/js/views/fields/ez-date-editview.js index 1bcc894bc..2dc6eb8de 100644 --- a/Resources/public/js/views/fields/ez-date-editview.js +++ b/Resources/public/js/views/fields/ez-date-editview.js @@ -74,10 +74,14 @@ YUI.add('ez-date-editview', function (Y) { * @protected */ _syncDateAttribute: function () { - var field = this.get('field'); + var field = this.get('field'), + date; if ( this._containsValidTimestamp() ) { - this._set('date', Y.Date.format(new Date(field.fieldValue.timestamp * 1000))); + date = new Date(field.fieldValue.timestamp * 1000); + + date.setTime(date.getTime() + date.getTimezoneOffset() * 60 * 1000); + this._set('date', Y.Date.format(date)); } }, @@ -260,6 +264,8 @@ YUI.add('ez-date-editview', function (Y) { } if ( this._containsValidTimestamp() ) { date = new Date(field.fieldValue.timestamp * 1000); + + date.setTime(date.getTime() + date.getTimezoneOffset() * 60 * 1000); } calendar = new Y.Calendar({ showPrevMonth: true, diff --git a/Resources/public/js/views/fields/ez-date-view.js b/Resources/public/js/views/fields/ez-date-view.js index 804dfad25..742de2a6f 100644 --- a/Resources/public/js/views/fields/ez-date-view.js +++ b/Resources/public/js/views/fields/ez-date-view.js @@ -50,8 +50,9 @@ YUI.add('ez-date-view', function (Y) { }, /** - * Formats the date part of the date object according to the locale - * settings of the browser + * Formats the date part of the date object. + * + * Uses UTC as that is what the date is stored in on server side. * * @method _formatDate * @protected @@ -60,7 +61,7 @@ YUI.add('ez-date-view', function (Y) { */ _formatDate: function (date) { return date.toLocaleDateString( - undefined, {year: "numeric", month: "short", day: "numeric"} + undefined, {year: "numeric", month: "short", day: "numeric", timeZone: "UTC"} ); }, });