I used the datetimepicker from: http://eonasdan.github.io/bootstrap-datetimepicker/Installing/
There no provide how to use function (date, show, hide, etc) so I don't know how to set the value for input using datetimepicker using date
function which says:
date([newDate])
Takes string, Date, moment, null parameter and sets the components model current moment to it.
I tried
$('#datetimepicker2').datetimepicker(
date: function() { return new Date(1434544649384); }
);
Where 1434544649384
is a timestamp.
But it doesn't work and doesn't update input text/value...
JsFiddle: http://jsfiddle.net/0Ltv25o8/1397/
quote from http://eonasdan.github.io/bootstrap-datetimepicker/Functions/
Note All functions are accessed via the data attribute e.g. $('#datetimepicker').data("DateTimePicker").FUNCTION()
So you can update date like following:
$('#datetimepicker2').data("DateTimePicker").date(new Date());
The correct syntax is :
$('#datetimepicker2').datetimepicker({
date: new Date(1434544882775)
});
Had to add, I was able to solve it.
$('#datetimepicker1').datetimepicker({});
$('#datetimepicker1').data("DateTimePicker").date(moment(new Date ).format('DD/MM/YYYY HH:mm'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With