Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 Timestamp isn't correct

I'm trying to get the current unix timestamp in AS3 via:

var date:Date = new Date();
var unix:int = date.time;

trace(unix);

For some reason I get:

2775219874

But when I use time() in PHP around the same time, I get:

1321330282

I don't understand?

I could of course request the timestamp from PHP via URLLoader, but I'd rather get it working properly without needing this if possible.

like image 835
Marty Avatar asked Nov 15 '11 04:11

Marty


1 Answers

The issue in my question was being caused by assigning date.time to int instead of Number.

See below for demo of assigning date.time to a variable:

var date:Date = new Date();

var uintVal:uint = date.time;
var intVal:int = date.time;
var numVal:Number = date.time;

trace(uintVal);     // 2776669556
trace(intVal);      // -1518297740
trace(numVal);      // 1321331629428
like image 133
Marty Avatar answered Sep 20 '22 13:09

Marty