9 lines
379 B
JavaScript
9 lines
379 B
JavaScript
//
|
|
// Add a method to get a timezone adjusted date for an input field that is a date picker.
|
|
// Use $('input[name="date"]').val(new Date().toDateInputValue()) to set the date of the input field.
|
|
//
|
|
Date.prototype.toDateInputValue = (function() {
|
|
let local = new Date(this);
|
|
local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
|
|
return local.toJSON().slice(0,10);
|
|
}); |