I've an input that is filled by jQuery/JS. Currently it fills the input with a date value like this 2017-3-7
but I want it to be 2017-03-07
.
I've a jsfiddle here: https://jsfiddle.net/ua8rngzw/
And the code is as follows:
(function ($) {
$(document).ready(function() {
var now = new Date();
var created = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
$('#created').val(created);
});
})(jQuery);
What is the easiest and quickest way to do such a thing?