Reputation: 1879
I'm using moments.js to set an input to current datetime. It works just fine for days, but I'd like to use the same for hours and minutes.
So far, I've been using this:
var today = moment();
var tomorrow = today.add(1, 'days');
$($selector).find('.datetimepicker').datetimepicker({
locale: global.locale,
minDate: date,
stepping: 15,
defaultDate: moment(tomorrow).format("YYYY-MM-DD")
});
So that my input is set to tomorrow. Unfortunately, it sets time to 12AM. Is it possible to set time to current one, and day to tomorrow ?
Upvotes: 0
Views: 1822
Reputation: 307
You just need to specify hh:mm in your output format.
You do not need to create a new moment out of your "tomorrow" object to format it either.
var today = moment();
var tomorrow = today.add(1, 'days');
$($selector).find('.datetimepicker').datetimepicker({
locale: global.locale,
minDate: date,
stepping: 15,
defaultDate: tomorrow.format("YYYY-MM-DD hh:mm")
});
Here is a working fiddle example: http://jsfiddle.net/vnbcgau2/
Upvotes: 2