views:

62

answers:

2

Hi All

We have a search utility that needs to search by date:

So I type in a date "04-20-1982" in the search field. In the code:

Alert.show("string date::"+message.searchKeyword);

dateOfBirth = DateField.stringToDate(message.searchKeyword,"MM-DD-YYYY");

Alert.show("date::"+dateOfBirth);

The first alert prints as string date::04-20-1982

The second alert prints as date::Tue Apr 20 00:00:00 GMT-0400 1982

The issue is our timezone is EST and since it changes it as GMT -400, it takes the time as Mon Apr 19 23:00:00 EST 1982 and does not return any results. The actual DOB in the DB is Apr 20 1982.

So please let me know how to avoid this conversion to GMT -400 Timezone and just send it as a date without any timezone.

Thanks

Harish

+2  A: 

Dates are transfered to/from Flex client as UTC date – no timezone information available. Transfer to the UTC/local time happens automatically on protocol level.

You can use something like this to get the offset and manually calculate the date:

 var dNow:Date = new Date();
        trace("Your time zone offset: " + dNow.getTimezoneOffset() + " minutes");
Todd Moses
Thank you for your response, Todd. I got the timezoneoffset in minutes and added those minutes to the date and voila, I get the right result. Not sure if this is the right solution, but it works for me!
Harish
A: 

I've recommended this approach on many occassions with success http://flexblog.faratasystems.com/2008/02/05/flex-local-datestime-transfer-issue

David Collie