0
votes

Here is a plunk demonstrating the problem. plunky

I have chosen the 'M!/d!' format. My control just requires the day and month so the year is not entered in the text box. If you erase the contents of the first textbox and enter a date in M!/d! format (e.g. 1/1) it is inferred as 1 Jan 1900. I want it to be inferred as 1 Jan 2016 (or whatever the currently selected year is) Is there a way to achieve this?

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

We have to use 'M!/d!' forma5t. There's no escaping it.

Thanks! :)

1
Isn't that going to be very confusing since some countries write day before month? Anyways, have a look at the datepicker API, I think you need to write a custom toValue function, since M!/d! doesn't seem automatically supported. bootstrap-datepicker.readthedocs.io/en/latest/…Shilly

1 Answers

0
votes

Give this a shot:

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

Hope that helps!