本站专用的
<?php function sydate($datetemp, $dstr = 'Y-m-d H:i',$mdstr = 'm月d日') { $timezone = Option::get('timezone'); $op = ''; $sec = time() - $datetemp; $min = floor($sec / 60); $hover = floor($sec / 3600); $day = floor($hover / 24); $month = floor($day / 30); $Year = floor($month / 12); if($Year==0){ if($min < 60){$op = "刚刚";} elseif($day < 1){$op = "24小时内";} elseif($day < 30) {$op = "{$day} 天前";} elseif($month < 12) {$op = gmdate($mdstr, $datetemp + $timezone * 3600);} } elseif($Year >= 1) {$op = gmdate($dstr, $datetemp + $timezone * 3600); }else{$op = "其他时间";} return $op; }?>
列表 <?php echo sydate($value['date']);?> 内容页 <?php echo sydate($date);?>
代码如下
<?php
function ssmartdate($datetemp, $dstr = 'Y-m-d H:i',$mdstr = 'm月d日') {
$timezone = Option::get('timezone');
$op = '';
$sec = time() - $datetemp;
$min = floor($sec / 60);
$hover = floor($sec / 3600);
$day = floor($hover / 24);
$month = floor($day / 30);
$Year = floor($month / 12);
if($Year==0){if($day < 30){$op = "{$day} 天前";}
elseif($month < 12)
{$op = gmdate($mdstr, $datetemp + $timezone * 3600);}
}
elseif($Year >= 1)
{$op = gmdate($dstr, $datetemp + $timezone * 3600);
}else{$op = "24小时之内";}
return $op;
}?>
列表引用
<?php echo ssmartdate($value['date']);?>
文章内页引用
<?php echo ssmartdate($date);?>