I use this datetimepicker:
http://eonasdan.github.io/bootstrap-datetimepicker/Options/
Basically I want to set maxDate: moment(), i.e maxDate should be limited to now.
The problem is by the time the datepicker is opened maxDate is not now() anymore.
I want to set it maxDate to now everytime the datepicker is shown.
I want to enforce it globally if possible, not to specify it on every datetimepicker() instance. Is it possible to somehow give a relative date to now using moment.js ?
See this fiddle:
https://jsfiddle.net/0Ltv25o8/3281/
I set maxDate to now. You'll see after minute from the page load, you won't be able to choose the current minutes using the arrow buttons.
maxDate: moment()should be enough to disable future dates (for every opening of the picker). Probably the issue is elsewhere in your code. You can use class selector on picker init to set config for all your instances or cache config object in a variable and then use the variable instead of repeating same values. You can manipulate moment objects usingadd/subtractetc as described in the docs - VincenzoC