1

Using an HTML <input type="datetime-local"> is it possible to not display the time markers? At the moment in Chrome, the watermark has

dd/mm/yyyy --:-- --

I only care about date so just want it to say

dd/mm/yyyy

I tried using the standard <input type="date"> which put the date in American format, which as I'm not American, nor in America, is useless.

  • -1 for your "useless to all right thinking people" comment. [The displayed format of the date for `date` input types is based on your browser's locale](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date)—it's not something you can specify independently. – André Dion Jan 26 '18 at 12:34
  • 1
    I'm in Britain where the format is dd/mm/yyyy, which as I'm in Britain *is* my locale. And I was taking the proverbial with the last bit. –  Jan 26 '18 at 12:36
  • You cannot modify the display format for `date` and `datetime-local` types. [They're automatically set based on your browser's locale _according to how it was installed_](https://stackoverflow.com/questions/673905/best-way-to-determine-users-locale-within-browser). If you need to customize the output, you'll need to use a regular `text` input. – André Dion Jan 26 '18 at 12:43
  • 1
    The date format follows your browser locale, not where you are. You can change the system locale to anything available when you are in Britain. – ild flue Jan 26 '18 at 12:44
  • My system locale is in Britain, my browser locale is Britain. In Chrome and Edge, the locale is registered and I get the correct format, in Firefox and others it doesn't. I've tried formatting the date input but none of them are particularly satisfactory, so I thought I'd try the new input which did the locale properly, but that contains more information than I need so wondered if I could get rid of the bit that I don't need. –  Jan 26 '18 at 12:52
  • Crystal clear now! – ild flue Jan 26 '18 at 13:15
  • And as I can't guarantee the end user's browser will be in British date format, it seems like a better plan to ensure it is in the format the end user will be expecting, rather than rely on those people having installed their programs to be British and not default American. –  Jan 26 '18 at 13:19

1 Answers1

0

then use type="date" instead, such as

<input type="date" mane="mydate">
ild flue
  • 1,323
  • 8
  • 9
  • You mean the type that I should said puts it in American date format ? –  Jan 26 '18 at 12:34
  • `type="datetime-local"` includes date AND time `--:-- --`; `type="date"` only has date, in the format of your locale of your browser. – ild flue Jan 26 '18 at 12:38
  • I know, my question is can it be removed/hidden? –  Jan 26 '18 at 12:39
  • In your question, you said only `dd/mm/yyy` is needed, then you only have `dd/mm/yyy` if you use the `date` type, instead of using `datetime` type – ild flue Jan 26 '18 at 12:41
  • Read the question, the date gives it in American format, which is not what he needs. datetime-locale gives the date in British format, but with the time, date gives it in American. – Glyn Jan 26 '18 at 12:44
  • Exactly, ideally what I need is`` which I'm fairly sure would be what most people's usage would be. –  Jan 26 '18 at 12:46
  • When your browser has an American locale, then it follows that locale. Yes, very right! it would be more flexible if the user can specify different locale in the `type` field. – ild flue Jan 26 '18 at 12:49
  • It's in BRITISH locale –  Jan 26 '18 at 12:53
  • This is the second time the same hyperlink has been posted but ignoring that, I'm not a moron, I checked my locale, I checked the language settings, I checked everything locale related before asking the question. Everything says "en-GB", "English (British)", etc. Regardless, it doesn't matter whether *my* browser is in English, end users may not be so I need to account for that. –  Jan 26 '18 at 13:22