| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>Date Input Test</title> |
| <style> |
| input { width: 300px; } |
| </style> |
| </head> |
| <body> |
| <!-- |
| The user-visible values of the input fields should be localized if the platform has |
| a LocalizedDate implementation. Otherwise, they should be in the HTML5 formats. |
| --> |
| <form method="get" action="#"> |
| <input title="test" type="date"><br> |
| <input type="datetime"><br> |
| <input type="datetime-local"><br> |
| <input type="month"><br> |
| <input type="time"><br> |
| <input type="week"><br> |
| </form> |
| <script> |
| // Tue Apr 26 2011 18:56:20 GMT-0700 (PDT) which is Wed Apr 27 2011 01:56:20 GMT. |
| var date = new Date(1303869380391); |
| var dateAsNumber = +date; |
| var inputs = document.getElementsByTagName("input"); |
| for (var i=0, len=inputs.length; i<len; ++i) { |
| var input = inputs[i]; |
| input.name = i; |
| if ("valueAsNumber" in input && input.type !== "month") |
| input.valueAsNumber = dateAsNumber; |
| else if ("valueAsDate" in input) |
| input.valueAsDate = date; |
| } |
| </script> |
| </body> |
| </html> |