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.

getTime()

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

Alert.show(date.toString());

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:

Alert.show(date.toUTCString());

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.

Related posts:

  1. Download Custom Flex 3 DateChooser
  2. Flex 3 Custom DateChooser
  3. Flex 3 Custom Preloader
This entry was posted in flex 3, web development and tagged , , , , , . Bookmark the permalink.

5 Responses to Flex 3 DateChooser UTC issue

  1. Klaus says:

    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.

  2. Stoimen says:

    Pretty nice solution, thanks again!

  3. shenshouer says:

    where can i download this? thanks

  4. Stoimen says:

    Actually there is no download link.

  5. cvg says:

    Thanks for information datechooser and UTC we need download link

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">