gae123
gae123

Reputation: 9457

How to set the ios 5 HTML5 input of type="date" to the current date & time?

I tried the obvious and does not work...

var dtel = document.getElementById("element-id");
dtel.value = new Date();

It needs a string but what is the syntax?

Upvotes: 1

Views: 551

Answers (1)

gae123
gae123

Reputation: 9457

After many trials and errors I found that the following works:

var dtel = document.getElementById("element-id");
var dt = new Date();
dtel.value = dt.toISOString();

Upvotes: 3

Related Questions