1

This question deals with a third-party plugin, but there may be enough crossover with the stock jquery UI datepicker that someone might be able to help out.

1) Set a maxDate of 0 or new Date() is set in the datetimepicker options

$('.foo').datetimepicker({maxDate:0})

2) Press "now" button

!3) Now button does not set time to the current time, but the time when the page was loaded

Example: http://jsfiddle.net/rf3gk/

How can I work around this? Is there a fix I can do, either in an external file or in the addon itself?

jumbopap
  • 3,969
  • 5
  • 27
  • 47
  • Why do you need a `maxDate` of 0? It's probably parsing that to December 1969 (that's what `new Date(0);` gives), and then updating improperly because now is much later than that. – CheeseWarlock Sep 03 '13 at 17:47
  • It's getting the proper time. The datepicker API accepts numbers as date offsets: http://api.jqueryui.com/datepicker/#option-maxDate – jumbopap Sep 03 '13 at 18:09

2 Answers2

0

I think you mean to be calling setDate, or similar in your plugin, see jQuery datepicker set selected date, on the fly.

Community
  • 1
  • 1
ars265
  • 1,949
  • 3
  • 21
  • 37
  • setDate won't work as it won't set a new maximum and allow sliders to go up to that; I would like the "Now" button to behave properly. – jumbopap Sep 03 '13 at 17:47
  • @subyraman, ok, so why wouldn't you just increase the max date at the same time you set the date to now? – ars265 Sep 03 '13 at 17:50
  • That doesn't increase the slider range and is causing the timepicker to crash when I try it. – jumbopap Sep 03 '13 at 20:43
0
$('.foo').datetimepicker({maxDate: '0'})

This will solve the problem.

change {maxDate: 0} to {maxDate: '0'}

Sobin Augustine
  • 3,639
  • 2
  • 25
  • 43
  • It does, but isn't this a partial fix? Now it will update properly, but the sliders allow exceeding the range past the current time. – jumbopap Sep 03 '13 at 18:03