user3304007 user3304007 - 2 months ago 8
jQuery Question

jQuery - How to check if time stamp in the value is older than 4500 miliseconds?

I need to check if the value in the input is older than 4500 miiliseconds.
How can I do that ?

html

<input type=hidden id="time" value="1276664400">


jquery

var currenttime = $.now();

if ($("#time").val() < currenttime) {

alert("I am older than 4500 miliseconds!");

}

Answer
var currenttime = $.now();
if ($("#time").val() < (currenttime - 4500)) {
    alert("I am older than 4500 miliseconds!");
}