101
rated 0 times
[
103]
[
2]
/ answers: 1 / hits: 22228
/ 9 Years ago, sun, october 18, 2015, 12:00:00
I have a HTML input box set to type=date
<input name=datereceived type=date class=FormDateValues id=datereceived />
I want to use Jquery to fill this input box on document load to today's date but because I am in Australia, I have to offset using GMT+10
To get the date, I do the following:
var newDate = new Date();
and then I tried to set the input box using the following:
$('#datereceived').val(newDate.toLocaleDateString());
The browser tells me that for type=date, the format must be set to yyyy-MM-dd and not the Australian time format of dd/MM/yyyy.
I am not sure how to go about enforcing the toLocaleDateString AND converting the date to yyyy-MM-dd.
More From » jquery