我在尝试使用 PHP 访问我的推特提要时得到以下结果:
Sat Apr 07 07:29:11 +0000 2012
如何更改它,使其仅" Apr 07
"?
我正在使用的代码:
$tweets = getTweets("http://twitter.com/status/user_timeline/justinbieber.json?count=3");
foreach($tweets as $tweet) {
$time = $tweet->created_at;
}
使用
strtotime()
将其转换为时间戳,然后使用 strftime()
或 date()
对其进行格式化。
echo strftime('%h %d', strtotime('Sat Apr 07 07:29:11 +0000 2012'));
# Apr 07
所以在你的情况下:
$time = strftime('%h %d', strtotime($tweet->created_at));
但是,调用包含月和日"时间"的变量是一个非常糟糕的主意。毕竟是约会。