Twitter のGMT フォーマットのpubDateをJST 何時何分前、何日前に変換するPHP関数
タウに頼まれてつくりました。
必要な方はご自由にご利用ください。。
$pubdate ="Sat, 10 Jul 2010 06:00:02 +0000";
$pubdate ="Tue, 13 Jul 2010 08:55:02 +0000";
echo getWhenTweeted($pubdate);//どれくらい前にツイートされたかをGMT日時から取得する
function getWhenTweeted($pubdate){
$updatetime = strtotime($pubdate);
$diffmin = round((time()-$updatetime)/60);
$update = gmdate("M d Y H:i:S", $updatetime+32400);
$hour = floor($diffmin/60);
$min = $diffmin%60;
if($hour < 24)
return $hour . "時間" .$min."分前";
else
return ceil($hour/24). "日前";
}