Reputation: 97
var startDateValuecmp = 29-July-2016;
I have start Date Value in 29-July-2016.
var endDateValuecmp=01-Aug-2016;
end Date Value 01-Aug-2016.
I want to compare this formate of date.
if (startDateValuecmp < endDateValuecmp) {
if (confirm("Please Check Event Date And Follow Up Date!!! Do you want to continue ?") == true) {
return true;
} else {
return false;
}
}
Upvotes: 0
Views: 71
Reputation: 5752
You can pass date to Date
builtin JavaScript class and then compare it
var startDateValuecmp = new Date('29-July-2016');
var endDateValuecmp = new Date('01-Aug-2016')
if ( startDateValuecmp < endDateValuecmp )
{
...
This will return boolean true
or false
based on condition.
This will return date in localtime zone, if concern about it use Date.UTC()
Refer this MDN Document.
This can't be invalid. Press button to Run this code
var startDateValuecmp = new Date('29-July-2016');
console.log("startDateValuecmp:", startDateValuecmp);
Upvotes: 1
Reputation: 718
Angular can direclty compare data if the input is well formatted.
If they're date object just compare them directly without .getTime() using ng-if
Upvotes: 1