Hi Jeremy,
I recommend converting your date into a native actionscript date object. This
has many benefits which include all of the date manipulation methods available,
the dateformatter class, correct date sorting in the datagrid, etc.
You can use
var date_from_db:String = "";
var d:date = new Date();
d.setTime(Date.parse(date_from_db));
Where date_from_db would equal one of the following string formats.
MM/DD/YYYY HH:MM:SS TZD
HH:MM:SS TZD Day Mon/DD/YYYY
Mon DD YYYY HH:MM:SS TZD
Day Mon DD HH:MM:SS TZD YYYY
Day DD Mon HH:MM:SS TZD YYYY
Mon/DD/YYYY HH:MM:SS TZD
YYYY/MM/DD HH:MM:SS TZD
I'm not familiar with CF but the way I do it in PHP using MySQL is in this SQL
query. The 'start_time' column is a datetime.
SELECT replace(start_time,'-','/') as start_time FROM mytable
In another project where I only receive the date in the format 'YYYY-MM-DD', I
use my own parseDate() method.
public function parseDate(s:String):Date
{
if (!s) return null;
var a:Array = s.split('-');
return new Date(parseInt(a[0]),parseInt(a[1])-1,parseInt(a[2]));
}
you would use it like:
var d:Date = parseDate('2007-01-01');
Hope this helps.
Cheers,
Adam
----- Original Message -----
From: Roman Protsiuk
To: [email protected]
Sent: Tuesday, March 20, 2007 7:16 PM
Subject: Re: [flexcoders] Flex dates
Formatter will "do that" only for displaying your date. And how it comes out
of database depends on database interface. In general you receive some
standardized date/time. If you want to get specifically formatted date out of
the database you should ask database to do it. Though I can't imagine why one
may need that kind of formatting.
R.
On 20 Mar 2007 01:47:16 -0700, flexjeremy <[EMAIL PROTECTED]> wrote:
Hi guys,
I am new to flex and have been having a huge learning curve. So be
gentle. I'm kinda new to REAL OO. But I know CF very well. So with
that said I'm stuck on dates.
I am trying to format a date coming out of a database so it will
look pretty. i.e. dd/mm/yyyy
I have an <mx:datefield id="DateIn"
text="remoteService.qryDrawdown.lastResult[0].DateIn"
formatString="DD/MM/YYYY"></mx:datefield>
Now I know that the formatString paramater does that for when you
choose it but how do you format it coming out of the database.
Currently its "Tue Feb 28 00:00:00 GMT" etc etc.
I found the <mx:dateFormater> tag but haven't been able to get it
working correctly.
Any Advise would be great!!
Jeremy