datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Disable default date and time on page load

Open lonewolf9277 opened this issue 7 years ago • 4 comments

Hi, I'd like to know how to prevent the datetimepicker from setting the value to current date/time. When the page first loads and the input is empty but not clicked yet, calling $("#datetimepicker1").datetimepicker('getValue'); returns the current time instead of null. I have tried setting defaultSelect to false.

lonewolf9277 avatar Jan 12 '18 15:01 lonewolf9277

Would also like to get a way to fix this. $("#datetimepicker1").datetimepicker('getValue'); should return null when the input is empty. Returning the current date is wrong, IMO. Also tried defaultDate: null, which does not work as well.

eljenso avatar Apr 23 '18 13:04 eljenso

Try setting the initTime and defaultSelect values to false.

I believe the first one should say whether the time provided in your field value is used as init time, and the second one should say whether it should be used as default value, but I don't think it's implemented very well because getCurrentValue() will set the value from your field regardless of the initTime setting.

askibinski avatar Apr 15 '19 14:04 askibinski

Has anyone found a solution?

samuel-clara avatar Oct 23 '19 16:10 samuel-clara

Try setting the initTime and defaultSelect values to false.

I believe the first one should say whether the time provided in your field value is used as init time, and the second one should say whether it should be used as default value, but I don't think it's implemented very well because getCurrentValue() will set the value from your field regardless of the initTime setting.

I tested this and it doesn't work. It only returns null if you click on the datetimepicker and delete the contents of the field. What I'm doing to validate that the field is null, is to check the field's val() and compare it with empty and/or with the mask I used.

hugos94 avatar Apr 22 '20 22:04 hugos94