input datetime does not show calendar

Asked

Viewed 106 times

1

I got my input datetime in this way:

<li>
<label for="DataQueda">Data/Hora Registo</label>
<input type="datetime" class="form-control" id="DataQueda" name="DataQueda" value="<?php echo date("Y-m-d H:i:s");?>">
</li>

Stay this way:

inserir a descrição da imagem aqui

But I would like to have this option in case I change the date:

inserir a descrição da imagem aqui

  • 2

    Have you tried separating the date and time in different fields? Have you tested whether the date output is being done correctly by PHP? Depending on the browser, datetiime separates date and time into fields, but note that this varies from implementation to implementation. Important [Edit] the post and provide a [mcve] of the problem and better describe how it tested, remembering that Stack Overflow accepts "executable" snippets of HTML

  • Either separate as Bacco said because most browsers have it, or you would have to use/create a Picker for it.

1 answer

2


I don’t know if it’s totally valid for you but you can change the type of datetime for datetime-local, the difference between them is that one has the option to declare the time zone and the other does not.

  • datetime: HTML5 A control to enter date and time (hour, minute, second and fraction of second) based on UTC time zone.
  • datetime-local: HTML5 A control to enter date and time, without time zone.

The type datetime, do not show the calendar in any browser, even in Chrome, already the datetime-local opens the calendar in Chrome, but does not have the spindle option.

inserir a descrição da imagem aqui

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

See how it looks in Chrome and Firefox

inserir a descrição da imagem aqui

Test yourself

Date / Datetime / Datetime-local<br>
<input type="date" name="" id="">
<input type="datetime" name="" id="">
<input type="datetime-local" name="" id="">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.