Greetings! I am currently working on a web application using AngularJS. I have a date value in AngularJS, for example 13-10-2017. In C#, I have the following field:
public DateTime LicenseExpiryDate { get; set; }
When I send 13-10-2017 in an AJAX request, LicenseExpiryDate is being accepted as 0001-01-01. Can someone please advise me on how to resolve this issue? I've noticed that my Angular date is in dd-mm-yy format, while C# date uses the default format yyyy-mm-dd.
I attempted to convert it to yyyy-mm-dd using the following function:
function formatDateDOsetyymmdd(date) {
debugger;
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [year, month, day].join('-');
}
However, when I test this function, it returns NaN-NaN-NaN. Any assistance would be greatly appreciated. Thank you!