|
require/common.php文件中整个函数为(前9行为注释,无实际意义,起说明作用): - /**
- * 获取友好的时间信息
- *
- * @global int $timestamp
- * @global string $tdtime
- * @param int $time 时间戳
- * @param int $type 类型
- * @return array
- */
- function getLastDate($time, $type = 1) {
- global $timestamp, $tdtime;
- static $timelang = false;
- if ($timelang == false) {
- $timelang = array('second' => getLangInfo('other', 'second'), 'yesterday' => getLangInfo('other', 'yesterday'),
- 'hour' => getLangInfo('other', 'hour'), 'minute' => getLangInfo('other', 'minute'),
- 'qiantian' => getLangInfo('other', 'qiantian'));
- }
- $decrease = $timestamp - $time;
- $thistime = PwStrtoTime(get_date($time, 'Y-m-d'));
- $thisyear = PwStrtoTime(get_date($time, 'Y'));
- $thistime_without_day = get_date($time, 'H:i');
- $yeartime = PwStrtoTime(get_date($timestamp, 'Y'));
- $result = get_date($time);
- if ($decrease <= 0) {
- if ($type == 1) {
- return array(get_date($time, 'Y-m-d'), $result);
- } else {
- return array(get_date($time, 'Y-m-d H:i'), $result);
- }
- }
- if ($thistime == $tdtime) {
- if ($type == 1) {
- if ($decrease <= 60) {return array($decrease . $timelang['second'], $result);}
- if ($decrease <= 3600) {
- return array(ceil($decrease / 60) . $timelang['minute'], $result);
- } else {
- return array(ceil($decrease / 3600) . $timelang['hour'], $result);
- }
- } else {
- return array(get_date($time, 'H:i'), $result);
- }
- } elseif ($thistime == $tdtime - 86400) {
- if ($type == 1) {
- return array($timelang['yesterday'] . " " . $thistime_without_day, $result);
- } else {
- return array(get_date($time, 'm-d H:i'), $result);
- }
- } elseif ($thistime == $tdtime - 172800) {
- if ($type == 1) {
- return array($timelang['qiantian'] . " " . $thistime_without_day, $result);
- } else {
- return array(get_date($time, 'm-d H:i'), $result);
- }
- } elseif ($thisyear == $yeartime) {
- if ($type == 1) {
- return array(get_date($time, 'm-d'), $result);
- } else {
- return array(get_date($time, 'm-d H:i'), $result);
- }
- } else {
- if ($type == 1) {
- return array(get_date($time, 'Y-m-d'), $result);
- } else {
- return array(get_date($time, 'Y-m-d H:i'), $result);
- }
- }
- }
=================分隔线==================== template/wind/lang_other.php 'yesterday' => '昨天', 'hour' => '小时前', 'minute' => '分钟前', 'qiantian' => '前天', 'second' => '秒前',
|