I have a date string and I want to convert it into a date object using date()
. It's doing so but the problem is, date()
processes any date as 'MM-dd-yyyy'.
I tried following code:
var myDate = '09-06-2017'; //which is a string and is in 'dd-MM-yyyy' format from my perspective
var selectedDate = new Date(myDate);
$scope.minDate = $filter('date')(selectedDate, 'yyyy/MM/dd');
console.log(selectedDate);
console.log($scope.minDate);
It will process this date as 06-09-2017 and if I pass '13-06-2017'(i.e. any value greater than 12) then it will throw 'Invalid Date' in console.
So I'm looking for a solution by which I can tell date()
to process the passed string in a specific format.
Thank You.