New to Javascript and WebOS, trying to implement an algorithim to check for a valid time-based authentication key, which lasts for four hours. I have a "keytime" property in my scene-assistant, which is updated when I get the authentication key. That appears to be working correctly. Then, when I'm ready to use the key (i.e. in a handleButtonPress event handler), I check against the current time to see if I'm within four hours.

This code, using all local variables works:

var keytime = new Date();
var nowtime = new Date();

t = (keytime > nowtime)? true: false;

document.write(" Keytime is " + keytime + " Now minus is " + nowtime + " test " + t);

output is:

Keytime is Fri Aug 14 19:13:50 CDT 2009 Now minus is Fri Aug 14 15:13:50 CDT 2009 test true

However, if I change everything to this.keytime, using the assistant property, the output is all still correct (i.e. the this.keytime shows the correct time, nowtime shows the correct time - four hours earlier than now), except the test returns false.

What is going on?