This deprecated warning is pretty annoying as it consumes about 30 lines in console.
Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.
aa/<@http://localhost:5050/js/app.min.js:5:23913
da@http://localhost:5050/js/app.min.js:5:24393
Ba@http://localhost:5050/js/app.min.js:5:28179
Aa@http://localhost:5050/js/app.min.js:5:28076
za@http://localhost:5050/js/app.min.js:5:27797
Ca@http://localhost:5050/js/app.min.js:5:28492
Da@http://localhost:5050/js/app.min.js:5:28526
a@http://localhost:5050/js/app.min.js:5:17110
c/y@http://localhost:5050/js/app.min.js:6:21388
c/da@http://localhost:5050/js/app.min.js:7:4183
c/l.minDate@http://localhost:5050/js/app.min.js:7:13492
c/l.options/<@http://localhost:5050/js/app.min.js:7:10498
.each@http://localhost:5050/js/app.min.js:1:12918
c/l.options@http://localhost:5050/js/app.min.js:7:10403
c@http://localhost:5050/js/app.min.js:7:22230
a.fn.datetimepicker/<@http://localhost:5050/js/app.min.js:7:22726
.each@http://localhost:5050/js/app.min.js:1:12864
_.prototype.each@http://localhost:5050/js/app.min.js:1:10841
a.fn.datetimepicker@http://localhost:5050/js/app.min.js:7:22591
@http://localhost:5050/Artifacts/Management
_.Callbacks/k@http://localhost:5050/js/app.min.js:2:4256
_.Callbacks/l.fireWith@http://localhost:5050/js/app.min.js:2:5073
.ready@http://localhost:5050/js/app.min.js:2:6866
g@http://localhost:5050/js/app.min.js:1:1729
I have explicitly disabled console.warn to avoid this warning using the cache-and-restore technique:
var cachedWarn = console.warn;
console.warn = function () { };
$mySelector.datetimepicker({...})
console.warn = cachedWarn;
I also get this warning. Does anyone know if it's definitely the datepicker that is causing it?
Yes, it's the datepicker what is causing the warnings. It is because moment.js changed its constructor, and this datepicker uses moment.js. More info on the issue:
http://momentjs.com/guides/#/warnings/js-date/
https://github.com/moment/moment/issues/1407
As @mrndig metioned, just overwrite createFromInputFallback, warning disappeared.
For what it's worth, I was able to remove the warning in my code by doing:
datePickerElement.datetimepicker().datetimepicker('defaultDate', initialDate);
instead of:
datePickerElement.datetimepicker({ defaultDate: initialDate });
This is caused by unreliable date/time formats. Just use any ISO one. e.g.:
instead of
defaultDate: "11/1/2013"
use
defaultDate: "2013-01-11"
probably @Eonasdan could change the documentation accordingly - just change the format?
Agree with @bouskdav
So whenever using a date string to config the datetimepicker, just use a JavaScript Date() object and call the toISOString() method.
For example, my case was setting today as the maxDate:
(javascript)
datetimepickerElement.datetimepicker({
maxDate: new Date().toISOString(),
format: "MM/DD/YYYY"
});
Most helpful comment
For what it's worth, I was able to remove the warning in my code by doing:
instead of: