Better Twitter date output

This commit is contained in:
Zach Copley 2009-10-05 17:11:32 -07:00
parent 475bdf6fba
commit f7688bec0d
1 changed files with 4 additions and 4 deletions

View File

@ -884,12 +884,12 @@ class TwitterapiAction extends Action
$this->end_document('xml'); $this->end_document('xml');
} }
// Anyone know what date format this is?
// Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach
function date_twitter($dt) function date_twitter($dt)
{ {
$t = strtotime($dt); $dateStr = date('d F Y H:i:s', strtotime($dt));
return date("D M d H:i:s O Y", $t); $d = new DateTime($dateStr, new DateTimeZone('UTC'));
$d->setTimezone(new DateTimeZone(common_timezone()));
return $d->format('D M d H:i:s O Y');
} }
// XXX: Candidate for a general utility method somewhere? // XXX: Candidate for a general utility method somewhere?