Recently, I integrated a date picker using moment.js, but it seems to be displaying the incorrect date. Strangely, when I displayed the date outside the date picker, it appeared correct. Upon checking the variables with console.log, I found that they were in the desired format. However, when calling the date in the date picker, it shows up in the wrong format. It should match exactly what is being outputted below the date picker. Can anyone help me figure out where I might be making a mistake?
Date picker and accurate date display:
https://i.sstatic.net/UtjL5.png
<div class="datepicker-container">
<div class="date-from">
From:
<datepicker date-set="{{yesterday}}" selector="form-control" date-max-limit="{{today}}" class="date-picker">
<div class="input-group">
<input class="form-control" placeholder="Choose a date"/>
<span class="input-group-addon" style="cursor: pointer">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</datepicker>
</div>
<div class="date-too">
To:
<datepicker date-set="{{today}}" selector="form-control" date-min-limit="{{yesterday}}" class="date-picker">
<div class="input-group">
<input class="form-control" placeholder="Choose a date"/>
<span class="input-group-addon" style="cursor: pointer">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</datepicker>
</div>
</div>
<h4>{{yesterday}} and {{today}}</h4>
Defining the date:
https://i.sstatic.net/ZcjmL.png
var currentDate = moment(new Date()).format("DD/MM/YYYY");
console.log("1", currentDate);
$scope.today = currentDate.toString();
console.log("2", $scope.today);
var yesterdaysDate = moment(new Date()).subtract(1, 'days').format("DD/MM/YYYY");
console.log("3", yesterdaysDate);
$scope.yesterday = yesterdaysDate.toString();
console.log("4", $scope.yesterday);