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

Jarin Udom picture Jarin Udom · Feb 13, 2009 · Viewed 20k times · Source

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?

Answer

Dan picture Dan · Feb 13, 2009

you have to convert to milliseconds, multiply that by 1000