0

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

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
returnvoid
  • 434
  • 1
  • 7
  • 19

2 Answers2

2

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
  • 5,029
  • 1
  • 21
  • 21
1

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
  • 27,696
  • 33
  • 111
  • 170
  • 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 2009 In 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 2010 what im doing wrong?? thanks – returnvoid Oct 27 '09 at 14:21