Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new Date().time or new Date.getTime() returning negative number?

if I trace new Date().toUTCString() I get something like: Fri Aug 12 07:14:06 2011 UTC. perfect. If I trace new Date().getTime() I get some long negative number which is decreasing as I continue to trace it. This is totally unexpected. Obviously my system clock is OK. What gives?

like image 231
Tom Auger Avatar asked Aug 12 '11 07:08

Tom Auger


1 Answers

new Date().getTime() returns time in milliseconds from January 1, 1970, universal time. It is positive number but I suppose you're using int to store it so Flash Player converts milliseconds to negative as far as it is more than int.MAX_VALUE. Use Number to store the value of new Date().getTime() and it will be positive.

like image 56
Constantiner Avatar answered Oct 23 '22 14:10

Constantiner