Javascript Date toDateInputValue()
// set today's date as new post date Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toJSON().slice(0,10); });//from ww w.j a v a 2s. com var dateField = document.getElementById('date-picker');
console.log('hi'); // Gets today's date and corrects for timezone // Use in the date picker input for default value (today) Date.prototype.toDateInputValue = (function() { var local = new Date(this); local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); return local.toJSON().slice(0,10); });/*from w w w . j a va2 s.co m*/