Twitter提要自发布后获得时间-php
我用这个来生成我的推特提要:Twitter提要自发布后获得时间-php,php,twitter,Php,Twitter,我用这个来生成我的推特提要: # Access as an object $tweetText = $tweet->text; $tweetDate = $tweet->created_at; # Make links active $tweetText = preg_replace("/(http:\/\/|www.)(([^\s<]{4,68})[^\s<]*)/", '<a href="http://$2$3" tar
# Access as an object
$tweetText = $tweet->text;
$tweetDate = $tweet->created_at;
# Make links active
$tweetText = preg_replace("/(http:\/\/|www.)(([^\s<]{4,68})[^\s<]*)/", '<a href="http://$2$3" target="_blank">$1$2$4</a>', $tweetText);
# Linkify user mentions
$tweetText = preg_replace("/@(w+)/", '<a href="http://www.twitter.com/$1" target="_blank">@$1</a>', $tweetText);
# Linkify tags
$tweetText = preg_replace("/#(w+)/", '<a href="http://search.twitter.com/search?q=$1" target="_blank">#$1</a>', $tweetText);
# Output
echo $tweetText;
echo '<br><span>Posted: ';
echo $tweetDate;
echo '</span>';
echo '<br> <br>';
#作为对象访问
$tweetText=$tweet->text;
$tweetDate=$tweet->created_at;
#激活链接
$tweetText=preg\u replace(“/(http:\/\/\www.)([^\s使用以下代码:
$tweetDate = strtotime($tweetDate);
$diff = time()-$tweetDate;
if($diff<60){
echo $diff." sec ago";
}else if($diff<(60*60)){
echo round($diff/60)." minute ago";
}else if($diff<(60*60*24)){
echo round($diff/(60*60))." hours ago";
}else{
echo round($diff/(60*60*24))." days ago";
}
$tweetDate=strottime($tweetDate);
$diff=time()-$tweetDate;
如果($diff$tweetDate
当前为2014年4月29日星期二09:43:17+0000
使用$tweetDate=strotTime($tweetDate);