0

我正在尝试使用 Zend_Date 格式化来自 Twitter API 响应的日期字段“created_at”。我想像这样输出日期:

2009年7月21日12:30:00(例)

这是什么格式?:

2009 年 10 月 23 日星期五 15:47:42 +0000

多谢

4

2 回答 2

2

我有最好的运气只是做

$d = new Zend_Date(strtotime($input));
$twitter_format_out = $d->toString('EEE MMM dd HH:mm:ss Z YYY');
于 2009-10-28T14:38:15.520 回答
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.

于 2009-10-26T10:02:51.333 回答