I am trying to create a Time difference function. And I need to be able to tell if CookieTime is pasted. I have tried some many different things and just can't seem to get it to work. Any suggestions on why this wont subtract?
I was able to successfully do a DateDiff last night with help: Javascript DateDiff
The error in my console is: Uncaught TypeError: Object 12:34:00 has no method 'getTime' Don't know if I understand what that means.
CookieTime = "12:34:00"; //Cookie time...
currTime = "05:11:55"; //Current Real Time...
function past(){
//Print the results for testing...
document.write(CookieTime + '<br>'); // = 12:34:00
document.write(currTime + '<br/>'); // = 05:11:55
// = Testing the results here = NaN
document.write(CookieTime.getTime() - currTime.getTime() + '<br/>');
if (CookieTime - currTime >= 0){
// Time has pasted!!
return true;
} else {
// Time is not here yet!!
return false;
}
}
document.write(past()); //Print response.
');` = Invalid Date! Can you tell me what I am doing wrong here? – Frank G. Aug 18 '12 at 09:50
'); //= 8-18-2012 document.write(CookieTime + '
'); //= 8-18-2012 12:34:00 document.write(currTime + '
'); //= 8-18-2012 05:59:49 CookieTime = new Date(currDate & ' ' & CookieTime); //Cookie time... currTime = new Date(currDate & ' ' & currTime); //Current Time.. ` Shows this as the value of both CookieTime and currTime: Wed Dec 31 1969 19:00:00 GMT-0500 (Eastern Standard Time) ? – Frank G. Aug 18 '12 at 10:02