0

这是一个演示问题的小块。 plunkyBootstrap UI日期选择器弹出窗口提取1900年作为年

我选择了'M!/ d!'格式。我的控制仅需要日期和月份,因此年份不会输入到文本框中。如果清除第一个文本框的内容并在M!/ d中输入日期!格式(例如1/1)推断为1900年1月1日。我希望它被推断为2016年1月1日(或任何当前选定的年份)有没有办法实现这一点?

$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate', 'M!/d!']; 
$scope.format = $scope.formats[4]; 

我们必须使用'M!/ d!' forma5t。没有逃脱它。

谢谢! :)

+0

因为有些国家在前一个月前写信,这会不会令人困惑?无论如何,看看datepicker API,我认为你需要写一个自定义的toValue函数,因为M!/ d!似乎没有自动支持。 https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#format – Shilly

回答

0

给这一个镜头:

$('#date').datepicker("setDate", new Date(2016,01,01)); 

希望帮助!

相关问题