Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex Date() constructor is mis-converting Unix time stamps argh

Tags:

People also ask

Which function returns the Unix timestamp for a date in PHP?

The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT).

How time stamp is calculated in Unix?

Here's an example of how Unix timestamp is calculated from the wikipedia article: The Unix time number is zero at the Unix epoch, and increases by exactly 86 400 per day since the epoch. Thus 2004-09-16T00:00:00Z, 12 677 days after the epoch, is represented by the Unix time number 12 677 × 86 400 = 1 095 292 800.

What is Unix timestamp format?

Unix time is a way of representing a timestamp by representing the time as the number of seconds since January 1st, 1970 at 00:00:00 UTC. One of the primary benefits of using Unix time is that it can be represented as an integer making it easier to parse and use across different systems.


This is seriously killing me. I'm trying to convert a Unix timestamp (1236268800, which equates to Thu, 05 Mar 2009 16:00:00 GMT) to a Date object in Flex.

var timestamp:Number = 1236268800;
trace(new Date(timestamp));

Output: Wed Jan 14 23:24:28 GMT-0800 1970

Also tried this:

var timestamp:Number = 1236268800;
var date:Date = new Date;
date.time = timestamp;
trace(date);

Output: Wed Jan 14 23:24:28 GMT-0800 1970

Either of those methods should work. What am I doing wrong here?