Reputation: 6189
The following javascript, processed via webpacker is setting the UI with the proper startDate (assuming today is 2020-12-19: 2018-12-19), but not the endDate, which is shown as 2020-12-19
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{
/***/ "./app/javascript/src/promotion_datespan.js":
/*!**************************************************!*\
!*** ./app/javascript/src/promotion_datespan.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function($) {$(function () {
var startDate = new Date();
startDate.setFullYear(startDate.getFullYear() - 2);
$('#date_from').fdatepicker({
initialDate: startDate,
format: 'yyyy-mm-dd',
disableDblClickSelection: true,
leftArrow: '<<',
rightArrow: '>>',
closeIcon: 'X',
closeButton: true
});
});
$(function () {
var endDate = new Date();
endDate.getDate(endDate.getDate() - 2);
$('#date_to').fdatepicker({
initialDate: endDate,
format: 'yyyy-mm-dd',
disableDblClickSelection: true,
leftArrow: '<<',
rightArrow: '>>',
closeIcon: 'X',
closeButton: true
});
});
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery/src/jquery */ "./node_modules/jquery/src/jquery.js")))
/***/ })
}]);
//# sourceMappingURL=0-0fcba24322adb18c7ad0.chunk.js.map
why is getDate
returning the wrong data?
Upvotes: 0
Views: 30
Reputation: 1062
You made a typo, use endDate.setDate
in stead off endDate.getDate
.
I assume you want the endDate
to be 2 days earlier then the current date.
Upvotes: 1