zhangjingyu
主要代码贴上:
/**
* 时间间隔处理
*/
function getAgotime($time,$rtasdate=false) {
global $timestamp,$config;
if ($rtasdate == true) {
return getTrueDate($time);
}
$between = $timestamp - $time;
if ($between < 60) {
$rt = $between . "秒前";
} elseif ($between < 3600) {
$rt = floor($between/60) ."分钟前";
} else {
if (!$config['timefmt']['hour'] && !$config['timefmt']['day'] && !$config['timefmt']['month']) {
$rt = getTrueDate($time);
} else {
if ($between < 86400){ //一天
if ($config['timefmt']['hour']) {
$hour = floor($between/3600);
if ($hour > $config['timefmt']['hour']) {
$rt = getTrueDate($time);
} else {
$rt = $hour."小时前";
}
} else {
$rt = getTrueDate($time);
}
} elseif ($between < 2678400) {//31天
if ($config['timefmt']['day']) {
$day = floor($between/86400);
if ($day > $config['timefmt']['day']) {
$rt = getTrueDate($time);
} else {
$rt = $day."天前";
}
} else {
$rt = getTrueDate($time);
}
} elseif ($between < 31536000) {//365天
if ($config['timefmt']['month']) {
$month = floor($between/2678400);
if ($month > $config['timefmt']['month']) {
$rt = getTrueDate($time);
} else {
$rt = $month."月前";
}
} else {
$rt = getTrueDate($time);
}
}
}
}
return $rt;
}
/**
* 获取实际日期
*/
function getTrueDate($time) {
/**
global $timestamp;
$Y1 = get_date($time,"Y");
$Y2 = get_date($timestamp,"Y");
if ($Y1 = $Y2) {
$rt = get_date($time,'m-d');
} else {
$rt = get_date($time,'Y-m-d');
}
return $rt;
*以上为原函数内容,不知道这个$time怎么来的?
*原滴答时间只显示月日,历史滴答也不显示年份
*2017年2月17日修改,同时让首页多格调用也显示如此
**/
$rt = get_date($time,'Y-m-d');
return $rt;
}
60行起的getTrueDate($time)这个函数可能写得不太好,所以让我给改了,就解决问题了。