Timezone Issues with remote (Date/Time) data and flash


We are wrapping up with this great charting application at cfwebtools, and we get a call from a customer that says our data is wrong….

We listen to them, and debug, and for some reason we just can’t quite see the same thing he see’s… On top of that, no one else is having the problem, but the fact is that, he has showed us screen shots, he’s duplicated on Four pc’s of his own, and he’s talked to 10 friends telling us that our data is wrong, and that there is mismatched days in our chart.

The problem:

When he was bringing up the charting application, the charts showed up successfully, but when you ta

ke a closer look, and you know your stuff about Financial Charting applications, you know what your looking for, and you know it with GREAT detail. So this guy, tells us our data is wrong, and pretty much with all of his friends proved to us SOMETHING was going wrong, but we couldn’t duplicate it.We tried trapping the data he was requesting when the request came in, we tried trapping it right before it went out… then we were using Kevin Langdon’s Service Capture to introspect the data that was coming in to flex.

The data is not that complicated, it looks like this:

Date: 2/20/08

Close: 31.53

Open: 30.61

Date: 2/19/08

Close: 30.93

Open: 30.94

but on his computer it looked like this:

Date: 2/19/08

Close: 31.53

Open: 30.61

Date: 2/18/08

Close: 30.93

Open: 30.94


the Date/Time objects were coming back from coldfusion, and it was returning coldfusion sql. They looked like this:

‘2/20/08 00:00:00′

‘2/19/08 00:00:00′

‘2/18/08 00:00:00′

what was really happening is that, flash auto adjusts for your Timezone… so what was really happening is the data is getting turned into this in flash (if they come back to flash as date/time objects)

Pacific Standard Time

‘2/19/08 22:00:00′

‘2/18/08 22:00:00′

‘2/17/08 22:00:00′

I’m sort of at a loss and i’m looking for help, there is one post that was more clear than the rest, but still doesnt solve my issue, it’s written by Ted Patrick of adobe. He states to use Universal Time, (UTC).

I have a problem with this!

I’m not the one creating the date times, nor do I get a chance to touch the data before it goes to my components… Of course I could obviously go in, to my result function of my remote object, or my command of cairngorm, and loop over the data, and adjust it all manually… BUT NOOOOO, I Don’t want to, what if i’m dealing with 40,000 records in a charting application (how bout we make it an even MILLION records, just to prove a point), then obviously the flash player has enough work to do on it’s own, without me looping through the data.

How do I query my database, and have it be a 00:00:00 time, and not have flash offset my date when it comes back to it?

For now, we manually change things in our query to add hours to the date time, but that is kind of sloppy…

Please check the example, and help me out if you can… Like I said I’m at a loss with this one.


2 comments on this post.
  1. PaulH:

    not that you want to hear this but if your datetimes were entered in local times & happen to fall on DST cusps then cf could also be chewing through your datetimes before they’re inserted in the db (to cf, all datetimes are server tz datetimes).

    really your best bet is to either store epoch offsets (ms since 1-jan-1970 UTC) or do as ted suggests & use UTC.

    i suppose you could try pushing this back on the db server (eg sql server):

    SELECT dateDiff(s,’1-jan-1970′,yourDateTime)*1000. as testDate
    FROM yourTable

  2. Chris:

    We ran into this problem, I solved it by using getter / setter utility on the way to / from the server. What was happening is that our servers store data in local time to the server, and flex converts to local time implicity…therefore we are duplicating the conversion to local time.

    As a result, I need to check the incoming and outgoing dates and set appropriately for the users local time, and so the server perceives it as the appropriate time / date, especially important when the data is being used outside of the flex app, only.

    Here is a cut / pasted example of my utilities:

    * I convert dates from DB / fluorine conversion
    * to the appropriate time to be used on the
    * client side app. The reason i am required
    * is due to a bug between our data servers and
    * the fluorine date conversion that implicitly
    * attempts to convert from UTC to local time
    public static function setDateOnGetFromDB(localDate:Date):Date{
    var offset:Number = localDate.getTimezoneOffset() * 60 * 1000;
    var UTCDate:Date = new Date(localDate.getTime() + offset);
    return UTCDate;

    * I do the opposite of setDateOnGetFromDB
    public static function setDatesOnSendToDB(UTCDate:Date):Date{
    var offset:Number = UTCDate.getTimezoneOffset() * 60 * 1000;
    var localDate:Date = new Date(UTCDate.getTime() – offset);
    return localDate;

Leave a comment