In my Javascript function, I am handling a C# DateTime received from MVC. If the date is null, it should return "-", and if it's a valid date, it should be returned in the formatted date.
IMPORTANT: The date must be sent in the specified format from C# and cannot be changed.
Javascript:
function CheckDate(date) {
if (date === "Mon Jan 01 0001 00:00:00 GMT+0000 (GMT Daylight Time)")
return "-";
else {
var parsedDate = new Date(date);
return parsedDate.getFullYear() + '/' + parsedDate.getMonth() + '/' + parsedDate.getDate();
}
Any suggestions for an improved method to compare dates with C# New DateTime?
Additionally, how can I parse and return the date in "yyyy/MM/dd" format?