Here you can find the source of toDateInputValue(()
// Lifted this idea (with slight modifications) for easily outputting a date value acceptable for use in a date input from // http://stackoverflow.com/questions/6982692/html5-input-type-date-default-value-to-today // I believe in attributing ideas, and when I need a quick solution if I can find one that // someone has already done well, I'm generally happy to learn, understand, and then use it, so // I can more quickly move to the next challenge. // Extend Date to output a value acceptable for date input field Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toISOString().substr(0,10); });//from w w w .j av a2 s. co m
Date.prototype.toDate = function(){ return new Date(this.getFullYear(), this.getMonth(), this.getDate());
Date.prototype.toDateFormat = function (format) { format = format || "yyyy/mm/dd"; return format.toLowerCase() .replace(/yyyy/g, this.getFullYear()) .replace(/yy/g, this.getYear()) .replace(/mm/g, this.getMonth2()) .replace(/m/g, this.getMonth() + 1) .replace(/dd/g, this.getDate2()) .replace(/d/g, this.getDate()); ...
Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()) return local.toJSON().slice(0,10);
Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toISOString().substr(0,10); });
Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toJSON().slice(0,10); });
Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toJSON().slice(0,10); });
Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toJSON().slice(0,10); });
Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toJSON().slice(0, 10); });
Date.prototype.toDateInputValue = (function() { var local = new Date(); return local.toJSON().slice(0,10); });