October: Saved date is subtracted by 1

Created on 10 Feb 2018  路  1Comment  路  Source: octobercms/october

Expected behavior

Hi, I'm using Builder to generate forms for my models. I am saving a record with a field which is type of date, when saved, the saved date should be the same with what I've inputted.

Actual behavior

After refreshing the page, the field shows a date one day lesser than what I've inputted. E.g., my input is January 26, 2018, after save and refresh, the field will display January 25, 2018.

Reproduce steps

Just create a model with a date field, choose a date, save, refresh, see that the date saved is one day lesser than what you've expected.

// app.php
'timezone' => 'UTC',

Background Preference Timezone: (UTC +08:00) Asia/Manila

October build

October build: 431

Question

Most helpful comment

That's because October automatically converts the date from the application timezone to the backend timezone on display; and also converts the date from the backend timezone to the application timezone on saving. To prevent this behaviour (i.e. store and display the dates exactly as entered, set the ignoreTimezone option to true on the datepicker and/or the datetime column. See http://octobercms.com/docs/backend/forms#widget-datepicker and http://octobercms.com/docs/backend/lists#column-datetime

>All comments

That's because October automatically converts the date from the application timezone to the backend timezone on display; and also converts the date from the backend timezone to the application timezone on saving. To prevent this behaviour (i.e. store and display the dates exactly as entered, set the ignoreTimezone option to true on the datepicker and/or the datetime column. See http://octobercms.com/docs/backend/forms#widget-datepicker and http://octobercms.com/docs/backend/lists#column-datetime

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mittultechnobrave picture mittultechnobrave  路  3Comments

m49n picture m49n  路  3Comments

LukeTowers picture LukeTowers  路  3Comments

d3monfiend picture d3monfiend  路  3Comments

mittultechnobrave picture mittultechnobrave  路  3Comments