AS3 Date Class, PHP and Unix Timestamps
This is a real quick post about Unix Timestamps, PHP, and ActionScript 3’s Date class. When creating a new Date instance, you can pass in a Unix Timestamp into the Date constructor.
[sourcecode lang=”php”]
var myDate:Date = new Date( unix_timestamp_from_php );
trace( myDate.toString() ); // Invalid Date
[/sourcecode]
When I was working with this, I continually received Invalid date in my output window. Looking into the matter, if you read php.net’s time() function description and then taking a look at livedocs Date class we’ll quickly see the problem.