views:

240

answers:

2

Hi everybody, im trying to formatting the date field 'created_at' from Twitter API response with Zend_Date. I want output the date like this:

21 of July of 2009, 12:30:00 (for example)

What format is this?:

Fri Oct 23 15:47:42 +0000 2009

thanks a lot

A: 

These date are not looking a standard format. Therefore, you have to create a format with the right constants (see them here).

Your first example (21 of July of 2009, 12:30:00):

$format = "d ' of ' MMMM ' of ' YYYY, h:mm:ss";

Your second example (Fri Oct 23 15:47:42 +0000 2009):

$format = "EEE MMM d h:mm:ss Z YYYY";

This formats you can use both for importing a date

$date = new Zend_Date($string, $format);

Or for outputting

$date->toString($format);

Look in the manual for locale support etc.

Peter Smit
Hi Peter, thanks for your answer.Twitter generate in the xml the node created_at with this date:Fri Oct 23 15:47:42 +0000 2009In Zend_Date Im trying $date = new Zend_Date('Fri Oct 23 15:47:42 +0000 2009');and for output:$date->toString('EEEE d MMM YYYY');but returns:wed 24 march 2010what im doing wrong??thanks
returnvoid
A: 

I've had the best luck just doing

$d = new Zend_Date(strtotime($input));
$twitter_format_out = $d->toString('EEE MMM dd HH:mm:ss Z YYY');
Justin
Justin, that gave me the right dateThank you
returnvoid
You can set me as the answer then :-)
Justin