I have a front-end form with two date fields. After upgrading to Craft 3 and implementing what I believe to be all the changes concerning front-end forms in Craft 3 I am experiencing some odd behavior.

The odd behavior

When I enter manually or use jQuery UI Datepicker plugin to enter a desired date into any of the date fields associated with this front-end form (this is the only front-end form on the site currently), the date gets saved one day behind. E.g. if I enter 2018-05-01 it gets saved as 2018-04-30. However, if I go to the admin area and add a new block to this matrix field it saves correctly.

What I changed when upgrading from Craft 2 to 3 is the following:

{{ getCsrfInput() }}
<input type="hidden" name="action" value="entries/saveEntry">


{{ csrfInput() }}
<input type="hidden" name="action" value="entries/save-entry">

I also checked and confirmed that I am using the most up-to-date version of jQuery UI to rule out the datepicker as the culprit.

Here is a gist of the form: https://gist.github.com/swthate/08152aefe2c481cd792fc156a9ea1bc6

Note: fields/inputs in question are on line 38 and line 49 of the gist (lotMixDate and lotExpireDate).


1 Answer 1


You need to include a timezone parameter to your form in order to get the correct one.

<input type="hidden" name="postDate[timezone]" value="America/Los_Angeles">

If you don't include something like this in your frontend chances are high you'll receive the wrong time because it adds/subtracts a certain amount of hours. As soon as you include a valid timezone it will calculate the correct time. Otherwise it will be set to the default system timezone which may differ from your local

  • Thanks! That makes a lot of sense. However, I am getting an array to string conversion error. I'm not sure why, because I confirmed that I am using the same hidden input form as the same field in the back-end: <input type="hidden" name="fields[scriptLots][new1][fields][lotExpireDate][timezone]" value="America/Chicago"> Commented May 1, 2018 at 18:49
  • Did you include your date parameter into the array as well? fields[scriptLots][new1][fields][lotExpireDate][date] Can you eventually show me the file and line number of the error? Another approach is to include the timezone into the string. Here is the rule github.com/craftcms/cms/blob/develop/src/helpers/… Commented May 1, 2018 at 19:02
  • Yep, I did add [date] to the end of the actual date input. The line that the error highlights at the top of the stack is line 171 of the file you linked to. Commented May 1, 2018 at 19:08
  • That means your submitted value is not an array. There must be something wrong with your HTML Commented May 1, 2018 at 19:10
  • Weird. The $_POST dump at the bottom of the error looks correct, to my nooby eyes. Here's a full shot of the error page: prnt.sc/jch5gc Commented May 1, 2018 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.