I am using bootstrap date time picker library and getting value from document like this.
var accountExpiry = jQuery(".tempExpiry input").val();
returns = "12 October 2015 - 03:35 PM"
and my goal is to compare accountExpiry time with Date.now()
and alert user Expiry must greater than current time.
I have tried following jquery but that is wrong:
var accountExpiry = jQuery(".tempExpiry input").val();
if (accountExpiry > Date.now()) {
console.log("OK");
} else {
console.log("Select time must be greater than current");
}
var accountExpiry = "12 October 2015 - 08:35 AM"; //change this with jQuery(".tempExpiry input").val()
var date = new Date(Date.parse(accountExpiry.replace(" -",""))) ;
if (date > new Date(Date.now())) {
console.log(date , new Date(Date.now()) ,"less");
} else {
console.log(date , new Date(Date.now()) ,"greater");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.