Answers.Body: <p>Where are you seeing the incorrect date, in the database or when you output it in the templates?</p>
  
  <p>I think Craft is probably working as expected here.</p>
  
  <p>Craft will expect the date submitted to be in the correct format for the locale it was submitted from, so will translate it from that format into UTC to save in the database.</p>
  
  <p>Then, when the date is output in templates, it is transformed again to the correct format for the locale it is being displayed in.</p>
  
  <p>The <code>EN</code> locale presumably assumes US date formatting so <code>01/02/2018</code> is correct as 2nd January 2018. For European locales, a date submitted as <code>01/02/2018</code> will correctly be recognised as 2nd February 2018.</p>
  
  <p>You need to make sure that the date input in your form is formatted according to the expected way for the locale the form is in.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T12:55:30.537Z
Answers.Text: I see it in the database. But isn't this a strange design choice? Because an input date field expects a certain format, it doesn't care about locales. And on top of that, the browser formats the date in the date field according to the users browser language, which can be different from the locale of the website. It probably is most of the time. So I would expect Craft to save it in a fixed locale (maybe if the field would be translatable it could do what it does now, then it would make sense). This behavior is good for Twig outputs but that's not always the use case!
Answers.UserDisplayName: Tom De Smet
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T12:56:52.880Z
Answers.Text: If you're seeing the "incorrect" date in the database, then I think that confirms what I said. I actually think this is logical behaviour from a user point of view. A user is going to expect to input a date in a format familiar to them which is the same format as they will expect to view dates. Craft is ensuring that this happens. Craft _is_ actually saving in a fixed locale _in the database_, i.e. UTC format.
Answers.UserDisplayName: Steve Rowling
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T13:07:26.210Z
Answers.Text: But the formatting of the date the user is inputting isn't controlled by Craft, it's controlled by the browser. If I set my browser to English I see 09/25/2018. If I set it to Dutch I see 25.09.2018. So the user doesn't care what Craft saves it as. The date field however does, it expects the format MM/DD/YYYY. So if Craft switches DD and MM for the users benefit, the browser and the datefield interprets the date wrong!
Answers.UserDisplayName: Tom De Smet
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T13:56:56.200Z
Answers.Text: Can you explain how you are setting the browser to English or Dutch? I'm not sure I understand what you mean by that. Do you mean that you are visiting the English or Dutch version of the site? Have you tested this in several browsers or just one? If several, do you get the same behaviour in all browsers?
Answers.UserDisplayName: Steve Rowling
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T14:03:00.527Z
Answers.Text: Also, are you using a `date` input field or a `text` input field?
Answers.UserDisplayName: Steve Rowling
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T15:00:51.263Z
Answers.Text: I have been using a date field but now I'm using a VueJS datepicker which is a text field that mimics a date field (but ultimately the behavior is the same, tested it both). I set the browser language by going into the settings of the browser and changing the language the browser is in. It has nothing to do with the website. (see docs here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Browser_compatibility).
Answers.UserDisplayName: Tom De Smet
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T12:40:01.433Z
Answers.LastActivityDate: 2018-09-25T12:40:01.433Z
Answers.UserDisplayName: Steve Rowling
Answers.Body: <p>The answer of Steve Rowling was correct. For a similar official answer by Brandon you can go here: <a href="https://github.com/craftcms/cms/issues/3325" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/3325</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-26T07:35:49.213Z
Answers.LastActivityDate: 2018-09-26T07:35:49.213Z
Answers.UserDisplayName: Tom De Smet
Body: <p>I have a website with multiple locales (English, Dutch, French, German and Spanish). I'm saving dates on a front-end form through Ajax, but it seems that Craft saves the dates in the locales' format, eg. in English, the 1st February 2018 would be 02/01/2018 and in Dutch it would be 01/02/2018.</p>
  
  <p>I'd think Craft would save all dates in the same format, disregarding any locale. I read somewhere that craft saves all dates in UTC format.</p>
  
  <p>When I'm in the locale EN and I pass the date 01/02/2018, expecting 2nd January 2018 to be saved, it saves OK.
  However, if I'm in NL, DE or FR and I pass the same date, it is saved as 1st February 2018 as these languages switch the day and month around.</p>
  
  <p>I always pass <code>MM/DD/YYYY</code> to the date field whatever locale. 
  I'm using the <a href="https://date-fns.org" rel="nofollow noreferrer">dateFns</a> library for formatting and the date it formats is correct. I use VueJS <a href="http://www.vcalendar.io" rel="nofollow noreferrer">v-calendar</a> as a datepicker which also shows everything correct.</p>
  
  <p>But when it's saved to Craft it suddenly switched day and month in the back-end!</p>
  
  <p>Any help or explanation, please? Seems like strange behavior choices.</p>
  
Tags: <datetime><ajax><frontend-form>
Title: Does Craft save dates in the locale format?
ThreadText: # Does Craft save dates in the locale format?
  
  (Asked by: username_0 on 2018-09-25)
  
  I have a website with multiple locales (English, Dutch, French, German and Spanish). I'm saving dates on a front-end form through Ajax, but it seems that Craft saves the dates in the locales' format, eg. in English, the 1st February 2018 would be 02/01/2018 and in Dutch it would be 01/02/2018.
  
  I'd think Craft would save all dates in the same format, disregarding any locale. I read somewhere that craft saves all dates in UTC format.
  
  When I'm in the locale EN and I pass the date 01/02/2018, expecting 2nd January 2018 to be saved, it saves OK.
  However, if I'm in NL, DE or FR and I pass the same date, it is saved as 1st February 2018 as these languages switch the day and month around.
  
  I always pass `MM/DD/YYYY` to the date field whatever locale.
  I'm using the [dateFns](https://date-fns.org) library for formatting and the date it formats is correct. I use VueJS [v-calendar](http://www.vcalendar.io) as a datepicker which also shows everything correct.
  
  But when it's saved to Craft it suddenly switched day and month in the back-end!
  
  Any help or explanation, please? Seems like strange behavior choices.
  
  **Tags:** datetime, ajax, frontend-form
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-09-25. Score: 1 | Accepted answer
  
  Where are you seeing the incorrect date, in the database or when you output it in the templates?
  
  I think Craft is probably working as expected here.
  
  Craft will expect the date submitted to be in the correct format for the locale it was submitted from, so will translate it from that format into UTC to save in the database.
  
  Then, when the date is output in templates, it is transformed again to the correct format for the locale it is being displayed in.
  
  The `EN` locale presumably assumes US date formatting so `01/02/2018` is correct as 2nd January 2018. For European locales, a date submitted as `01/02/2018` will correctly be recognised as 2nd February 2018.
  
  You need to make sure that the date input in your form is formatted according to the expected way for the locale the form is in.
  
  > **Comments:**
  > **username_0**: I see it in the database. But isn't this a strange design choice? Because an input date field expects a certain format, it doesn't care about locales. And on top of that, the browser formats the date in the date field according to the users browser language, which can be different from the locale of the website. It probably is most of the time. So I would expect Craft to save it in a fixed locale (maybe if the field would be translatable it could do what it does now, then it would make sense). This behavior is good for Twig outputs but that's not always the use case!  
  > **username_1**: If you're seeing the "incorrect" date in the database, then I think that confirms what I said. I actually think this is logical behaviour from a user point of view. A user is going to expect to input a date in a format familiar to them which is the same format as they will expect to view dates. Craft is ensuring that this happens. Craft _is_ actually saving in a fixed locale _in the database_, i.e. UTC format.  
  > **username_0**: But the formatting of the date the user is inputting isn't controlled by Craft, it's controlled by the browser. If I set my browser to English I see 09/25/2018. If I set it to Dutch I see 25.09.2018. So the user doesn't care what Craft saves it as. The date field however does, it expects the format MM/DD/YYYY. So if Craft switches DD and MM for the users benefit, the browser and the datefield interprets the date wrong!  
  > **username_1**: Can you explain how you are setting the browser to English or Dutch? I'm not sure I understand what you mean by that. Do you mean that you are visiting the English or Dutch version of the site? Have you tested this in several browsers or just one? If several, do you get the same behaviour in all browsers?  
  > **username_1**: Also, are you using a `date` input field or a `text` input field?  
  > **username_0**: I have been using a date field but now I'm using a VueJS datepicker which is a text field that mimics a date field (but ultimately the behavior is the same, tested it both). I set the browser language by going into the settings of the browser and changing the language the browser is in. It has nothing to do with the website. (see docs here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Browser_compatibility).  
  
  ---
  
  ### Answer by username_0 on 2018-09-26. Score: 0
  
  The answer of username_1 username_1 was correct. For a similar official answer by Brandon you can go here: <https://github.com/craftcms/cms/issues/3325>
  
  
  ---
  
  