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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With