如何从bootstrap datepicker获取今天的日期

时间:2016-07-27 10:51:06

标签: javascript jquery twitter-bootstrap datepicker bootstrap-datepicker

我正在使用bootstrap datepicker,我想使用datepicker的内置函数。 我该怎么用?

^

我使用这个https://bootstrap-datepicker.readthedocs.io/en/latest/index.html datepicker。它工作正常但我想根据我的需要做一些改变。我想getCurrentDate并做一些计算,然后再次退回。如何使用此datepicker实现此功能。

1 个答案:

答案 0 :(得分:0)

试试这样:

var toDate = $('#datepicker').datepicker(

).on('change', function(e) {
    console.log(e);
});

// here i need current date and do some calculation and then set again.

toDate = $('#datepicker').datepicker('update',new Date());
console.log(toDate);

//if want to update again 
toDate = $('#datepicker').datepicker('update','2016-08-16');
相关问题