ActionScript Date Comparison
I was just staring a a piece of ActionScript code trying to figure out why the two date objects I was comparing were not coming up equal. I'm ashamed to say I didn't notice the problem at first because I had mistakenly typed
1 if(date1 = date2)
Two equals signs ("==") work a little better than one since the single operator obviously changes the value of the former operand. :) Once I fixed that, I found my real problem.
Turns out that ActionScript (like JavaScript) does not like to compare dates directly. It stores them as a number of milliseconds since an epoch date on January 1st, 1970. The .getTime() method of a date object will return you those milliseconds which is what you use to make the comparison.
1 if(date1.getTime() == date2.getTime())
TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
[Add Comment]
[Subscribe to Comments]
# Posted By radekg
| 10/15/08 1:58 AM
# Posted By Brad Wood
| 10/15/08 2:37 AM
[Add Comment]
