HTML5 date type input fields, not perfect yet

{}
February 25th, 2011

One of the most handy improvements of HTML5 will be the added functionality to forms. Sliders, spinners and datepickers are foreseen and IMHO will be extremely valuable. No need anymore for the Jquery datepickers, which are nice but quite a hassle for a thing that should be standard: inputting a date.

Opera is the only browser that supports the HTML5 type=datetime attribute at the moment.
Unfortunately there areĀ  some pitfalls.

What is the right date-format?

The HTML spec states several valid datetime formats. Opera doesn’t parse these correctly.

Birthday of Nero: 0037-12-13T00:00Z

Why is this a valid date 2010-09-30T12:00:00 while the default MySQL output 2010-09-30 12:00:00 isn’t? That’s just plain stupid.
It means that every webdeveloper needs to add extra steps to parse the database fields with extra code in scriptlanguage.
For PHP:

<input type="datetime-local value="<?= date('Y-m-d\TH:m',strtotime($event_start)) ?>">

That’s not very HTML5-wise; what works is OK, don’t make it more difficult than that. Now the most intuitive thing doesn’t work, that’s no good.

Tags:

Leave a Reply