I had the same thing just a few weeks ago.  Note here that I'm already
passing the date back 0-based and not passing the time, but this will
essentially do what you want.

private function parseDates(data:String):Date {
        // Get an array of Strings from the comma-separated String
passed in.
        var a:Array = data.split("-");

        // Create the new Date object. Note that the month argument is
0-based (with 0 being January).
        var newDate:Date = new Date(a[0],a[1],a[2]);
        return newDate;
} 

Enjoy.

Tim Rowe
Software Engineer
carsales.com Ltd
 
Level 1, 109 Burwood Road
Locked Bag 3333
Hawthorn VIC 3211
 
t: 03 9093 8600 (Reception)
t: 03 9093 8757 (Direct)
f: 03 9093 8697

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Mark Easton
Sent: Tuesday, 16 September 2008 10:22 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Convert String to Date?



Gosh, I cant believe I am asking this question. But, other than parsing
the string I cannot see anyway to obviously convert my string to a date
format. My string is returned from a SQL query and passed to my app via
XML.
 
So my string is in the format:  YYY-MM-DD HH:M:SS. This is a standard
SQL format. So why can I not easily convert that in to a date format in
flex?
 
I have looked at the Date and DateField classes but no help there.
DateField.stringToDate for instance only accepts date formats (no time).
Date for instance wants a date in the format (as follows) ... 
 
var date:Date = new Date("Mon May 1 2006 11:30:00 AM");
 
Hmmm - what a pain! Any one have a solution?
 
TIA
Mark
 
 
 
 
<http://geo.yahoo.com/serv?s=97359714/grpId=12286167/grpspId=1705007207/
msgId=125320/stime=1221523430/nc1=4507179/nc2=3848641/nc3=4836036> 


 

Reply via email to