I'm inserting the date into the database using md-datepicker, for eg, if I insert 20/09/2019, it is getting inserted as 19/09/2018 in the database.
It would be good, if this issue gets fixed in front end itself. And also, I want the datepicker to be read-only i.e, the user can select, but shouldn't enter the date in the datepicker texbox
<md-datepicker ng-model="data.date" md-placeholder="Choose a date" md-max-date="maxDate"></md-datepicker>
 
$scope.maxDate = new Date();
$scope.data = { date: new Date() }; 
  
.config(function ($mdDateLocaleProvider) {
    $mdDateLocaleProvider.formatDate = function (date) {
        return date ? moment(date).format('DD/MM/YYYY') : '';
    };
});
The date is coming exact in the post method, but when inserted into the database, it is getting inserted as the previous date i.e. selected date - 1
 
    $scope.submit = function () {
        var a = $scope.mydata.length;
        for (var i = 0; i < a; i++) {
            debugger;
            var paymentDetails = {
                "InvoiceId": $scope.SelectedInvoice.originalObject.InvoiceId,
                "InvoiceAmount": $scope.mydata[i].CurrencyAmount,
                "ReceiptAmount": $scope.mydata[i].replica,
                "DocNo": $scope.docNo,
                "DispatchId": $scope.mydata[i].DispatchId,
                "CreatedBy": $scope.username,
                "PaymentDate": $scope.data.date
            };
            if ($scope.mydata[i].replica == $scope.mydata[i].CurrencyAmount && typeof ($scope.docNo) != "undefined") {
                debugger;
                $http({
                    method: "POST",
                    url: apiUrl + "/api/Warehouse/addPaymentDetails",
                    data: JSON.stringify(paymentDetails),
                    dataType: 'json',
                    contentType: 'application/json'
                }).then(function (data, status) {
                    $scope.issueDetails = "";
                });
                alert("Super");
            }
        }