We can create an <input> element with type="datetime" via the document.createElement()
method:
var x = document.createElement("INPUT"); x.setAttribute("type", "datetime");
Click the button to create a Datetime field.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w ww . j a v a 2s. c o m*/ var x = document.createElement("INPUT"); x.setAttribute("type", "datetime"); x.setAttribute("value", "2000-02-02T08:32Z"); document.body.appendChild(x); } </script> </body> </html>