You could use new Date(dateStr); However, if the date string contains hyphens it will be invalid and fail.
If the hyphens in the date string are not under your control then you can swap them out for nice valid forward slashes: var dateStr:String = "2012-11-21 11:11:00"; dateStr = dateStr.split("-").join("/"); var doomsDay:Date = new Date(dateStr); Regards, Keith Reinfeld Home Page: <http://keithreinfeld.home.comcast.net/> http://keithreinfeld.home.comcast.net From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of powers Sent: Tuesday, November 17, 2009 1:58 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Comparing Dates: ObjectUtil.dateCompare not working @Keith What would you recommend to use instead of DateField.stringToDate to parse a string into a date object so that it doesn't strip off the time portion? Date.parse does not correctly parse a date when the string is formatted as YYYY-MM-DD HH:NN:SS. Keith Reinfeld wrote: > > ObjectUtil.dateCompare() function does account for the time portion of the > supplied dates. > > > > According to the scenario you describe ObjectUtil.dateCompare() function > never sees the time portion of date_A nor date_B. > > > > The DateField.stringToDate() method only evaluates the YYYY-MM-DD portion > of > the supplied date string and ignores/strips off the time portion of the > date. > > > > Regards, > > > > Keith Reinfeld > Home Page: <http://keithreinfeld.home.comcast.net/> > http://keithreinfeld.home.comcast.net > > > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of powers > Sent: Monday, November 16, 2009 2:29 PM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Comparing Dates: ObjectUtil.dateCompare not working > > > > > > > I'm writing a sort compare function to sort by date. The date format is > YYYY-MM-DD HH:NN:SS. I'm converting the dates, in a string format, to a > Date objects like so: > > DateField.stringToDate(date_A 'YYYY-MM-DD HH:NN:SS'); > DateField.stringToDate(date_B 'YYYY-MM-DD HH:NN:SS'); > > Then comparing the dates like this: > > ObjectUtil.dateCompare(date_A, date_B) > > It always returns 0 when the date portion of the two date objects are > equal, > but the times are different. Does the ObjectUtil.dateCompare function not > account for the time? > > -- > View this message in context: > http://old.nabble.com/Comparing-Dates%3A-ObjectUtil.dateCompare-not-working- > tp26378917p26378917.html > Sent from the FlexCoders mailing list archive at Nabble.com. > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.425 / Virus Database: 270.14.67/2506 - Release Date: 11/16/09 > 07:43:00 > > > > > -- View this message in context: http://old.nabble.com/Comparing-Dates%3A-ObjectUtil.dateCompare-not-working- tp26378917p26396451.html Sent from the FlexCoders mailing list archive at Nabble.com. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.425 / Virus Database: 270.14.68/2507 - Release Date: 11/17/09 07:40:00
<<image001.jpg>>
<<image002.jpg>>