0

I'm using an <input type="date"> element. Can I assume that the value attribute always needs to be in the format: "yyyy-MM-dd"?

That is, regardless of the region/country that the browser is being used?

Zach Smith
  • 8,458
  • 13
  • 59
  • 133

2 Answers2

2

Yes. The value attribute always has the format: YYYY-MM-DD. However, the presentation format is different depending on the user's locale. See my answer here for further details.

David Walschots
  • 12,279
  • 5
  • 36
  • 59
-1

Yes, David Walschots wrote in his answer here:

Wire format The HTML5 date input specification refers to the RFC3339 specification, which specifies a full-date format equal to: yyyy-mm-dd. See section 5.6 of the RFC3339 specification for more details. so if you want to set max or min you can use the format Y-m-d for example 2000-01-01

Presentation format Browsers are unrestricted in how they present a date input. At the time of writing Chrome, Edge, Firefox and Opera have date support (see here). They all display a date picker and format the text in the input field.

... but inconsistently use slashes (30/01/2018) where for example dashes (30-01-2018) are expected by the locale's calendar format.

David Walschots
  • 12,279
  • 5
  • 36
  • 59
bnabriss
  • 99
  • 6
  • thanks - could you clarify what this means? "Yes, but inconsistently use slashes (30/01/2018) where for example dashes (30-01-2018) are expected by the locale's calendar format." – Zach Smith Apr 11 '18 at 14:37
  • it means that it depends on browser, but they are all almost the same (but not exactly the same) they have a little bit difference. so for readers there is no difference because reader can read it if it slash or dash, but in coding it different – bnabriss Apr 11 '18 at 17:57
  • @bnabriss you're not following the [rules on referencing material written by others](https://stackoverflow.com/help/referencing). Could you please adapt your answer? – David Walschots Sep 20 '18 at 17:43
  • @DavidWalschots , sorry for that, I have edited my answer. – bnabriss Sep 23 '18 at 13:19
  • @bnabriss you forgot to include the first bit. So I've edited your answer accordingly. – David Walschots Sep 23 '18 at 19:47