如何使用CakeTime:timeAgoInWords获得相对时间而不是绝对时间?
例如:
about one week ago而不是
1 week, 2 days ago发布于 2014-02-17 19:01:26
根据需要创建自己的方法来处理这些问题。还可以实现像int_to_words()这样的函数这。
类似于:
function relativeTime($time){
$arrray = explode(" ",$time); // transform time in array of words
if(array[1] == "week,"){
if(array[2]) > 5){
return "Almost two weeks ago";
}
return "About one week ago";
}else if(array[1] == "weeks"){
$aux = array[0];
$number = int_to_words($aux);
return "About $number week ago";
}
// Read more about the possible CakeTime:timeAgoInWords results
// and continue to implement the other possibilities here...
}https://stackoverflow.com/questions/21795577
复制相似问题