I am having to try to determine whether a date from a hidden field, formatted mm/dd/yyyy, is less than today. if it is, I want to let the person know that a subscription has expired. I have had this working on some occasions but it is not reliably doing it??
//this is the expiration date that is in a hidden field
var expireDate = $("#expire").val();
//here I am trying to setup a new date for today and change the output to match the date
//format for the hidden field, i.e. mm/dd/yyyy
var a = new Date();
var b = a.toISOString().split("T")[0].split("-");
var ca = b[1] + "/" + b[2] + "/" + b[0];
//now I want to compare the 2 and if the expiration date is less than today, display a warning message
if (expireDate < ca) {
$("<div class=\"message-warning\">This subscription is expired</div>")
.insertAfter("#enddate");
};