mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
增加访问记录功能
This commit is contained in:
@@ -77,7 +77,7 @@ function get_source_link($url)
|
||||
{
|
||||
|
||||
if (empty($url)) {
|
||||
$url = '/static/images/avatar.jpeg';
|
||||
$url = '/static/images/avatar.png';
|
||||
}
|
||||
if (strpos($url, '/') === 0) {
|
||||
return $url;
|
||||
@@ -302,4 +302,26 @@ if (!function_exists('ua_htmlentities')) {
|
||||
|
||||
return htmlentities($string);
|
||||
}
|
||||
}
|
||||
|
||||
function show_time_ago($timestamp) {
|
||||
$current_time = new DateTime();
|
||||
$target_time = new DateTime("@$timestamp");
|
||||
$interval = $current_time->diff($target_time);
|
||||
|
||||
if ($interval->y > 0) {
|
||||
$result = $interval->format('%y 年前');
|
||||
} elseif ($interval->m > 0) {
|
||||
$result = $interval->format('%m 个月前');
|
||||
} elseif ($interval->d > 0) {
|
||||
$result = $interval->format('%d 天前');
|
||||
} elseif ($interval->h > 0) {
|
||||
$result = $interval->format('%h 小时前');
|
||||
} elseif ($interval->i > 0) {
|
||||
$result = $interval->format('%i 分钟前');
|
||||
} else {
|
||||
$result = $interval->format('%s 秒前');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
Reference in New Issue
Block a user