6

I'm using the HTML5 <input type="date">, which in Chrome renders a rich input control displaying the date in the format MM/DD/YYYY. The problem is that my application expects input in a localized format server-side, which means MM.DD.YYYY.

Is there any way I can change the way Chrome renders and takes input from date controls?

Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
Nilzor
  • 18,082
  • 22
  • 100
  • 167
  • 2
    The format submitted to the server has to be `yyyy-mm-dd` [HTML5: date, RFC 3339](http://dev.w3.org/html5/markup/input.date.html), depending on the system settings of the user the browser is free to display it in another format, but it will always be submitted in the [RFC 3339](http://tools.ietf.org/html/rfc3339) format, so you should change your server side code to handle that respecting the standard. If this is not possible you either need to change the format yourself using js before submitting or you can't use ``. – t.niese Feb 12 '14 at 07:53
  • I can change the server code. Next question is how do I configure Chrome to display local date format? I can't remember choosing language or culture when installing Chrome. My windows "regional settings" is set to `mm.dd.yyyy` while Chrome displays `yyyy-mm-dd` – Nilzor Feb 12 '14 at 10:02
  • Ok, found it under settings > advanced > language. If you want an accepted answer, post your comment as an answer together with this piece of information. – Nilzor Feb 12 '14 at 10:08

2 Answers2

6
  1. Chrome renders the date on the format for the language configured in Settings > Language:

    Chrome language settings

  2. Chrome (and other browsers) always post dates in RFC 3339-format according to the HTML5 standard. Make sure the server accepts date on that format only.

Community
  • 1
  • 1
Nilzor
  • 18,082
  • 22
  • 100
  • 167
  • 4
    This forces me to change the UI language to have a different date format rather than use what is defined in the Windows settings. On Mac OS X and some Windows, it is using the OS settings. For example, I might want to have my Chrome is English and the European date format (dd-mm-yyyy). Apparently, the Chrome team didn't think was an option. – Eric Darchis Jul 30 '14 at 14:53
  • @EricDarchis I had the same problem, so I switched to English (UK). I know it's not exactly what you want, but it's good enough... at least for me :) – zkristic Jan 19 '16 at 08:32
0

Good idea to post to the data base in YYYY-MM-DD format, but offer to HTML-5 user (independently of browser) either DD-MM-YYYY or MM-DD-YYYY. Need to allow script writer to decide when coding the <INPUT..>.

dampee
  • 3,392
  • 1
  • 21
  • 37
  • Hello, looks like your answer might be incomplete - stopped mid-sentence. Please ignore if that's not the case. Thanks! – Chait Mar 30 '17 at 23:14