Flex 3 DateChooser UTC issue

What I intend to do

The task can be described as it is. There’s a Flex 3 DateChooser component integrated with a custom timeline component. The problem occurs when exporting the data from the flash to the browser. Than I write the unix timestamp to the url of the browser. Of course I’m using date.getTime() in Flex.


Applying getTime() to any object of type Date in Flex results in a unix timestamp with included milliseconds. Of course the server side technology which in our case is PHP should devide by 1000 to remove the milliseconds.

The problem

The database and the server side script language use a UTC dates. The problem is the Flash functions getFullYear, getMonth, etc. don’t deal with UTC. Of course you can switch to getUTCFullYear, getUTCMonth, etc. but than comes the real problem.

The DateChooser …

When you’re using dates in Flex with no UTC in mind everything’s OK. You have the DateChooser component. Clicking on the 16th of May 2009 results in


which prints 16th of May 2009, which appears to be OK. Yes but the date.getTime() is still using the non-UTC time. If you’re using UTC, and suddenly print that kind of a message:


Then for 16th of May 2009 you receive 15th of May 2009. Which is really bad.

No workaround

Unfortunately I didn’t find any workaround till now. I hope I’ll soon.

5 thoughts on “Flex 3 DateChooser UTC issue

  1. I had a similar problem but instead of passing the timestamp to the php script y passed the date.toString() result and in the PHP backend i used the strtotime function and viola.

Leave a Reply

Your email address will not be published. Required fields are marked *