Hi guys, how do I go about setting defaultDate?
Currently:
var dd = moment("31/05/2016 09:00", "DD/MM/YYYY HH:mm");
var dd2 = "31/05/2016 09:00";
dateInput.datetimepicker({
format: 'DD/MM/YYYY HH:mm',
defaultDate: dd,
minDate: moment(),
maxDate: moment().add(1, 'year'),
});
How do I achieve this, been racking my brains for the best part of a day.
dd2 I get the error: defaultDate() Could not parse date parameter: 31/05/2016 09:00dd it's just the current date?Confused..
I have solved this problem, parameter 'minDate' cannot use together with 'defaultDate', I try to remove 'minDate' and use 'defaultDate' only.. awesome it works. but actually it should use 'minDate' to limit the date.
Sorry for my english.
Hi,
Parameter defaultDate does not work so in order to achieve the goal use the below lines of code.
HTML
input type='text' class="form-control" id='datetimepicker5' placeholder="Select to date" value='<?php echo $myDate?>'// $myDate is having value '2016-02-23'
Note - If You are coding in php then you can set the value of the input datefield using php, but datetimepicker sets it back to current date when you apply datetimepicker() function to it. So in order to prevent it, use the given JS code
JAVASCRIPT
$('#datetimepicker5').datetimepicker({
useCurrent: false, //this is important as the functions sets the default date value to the current value
format: 'YYYY-MM-DD'
});
Most helpful comment
Hi,
Parameter defaultDate does not work so in order to achieve the goal use the below lines of code.
HTML
Note - If You are coding in php then you can set the value of the input datefield using php, but datetimepicker sets it back to current date when you apply datetimepicker() function to it. So in order to prevent it, use the given JS code
JAVASCRIPT