PHP -- 분전 / --시간전으로 리스트에 표시하기
페이지 정보
작성자 IN-BEST 댓글 0건 조회 14,645회 작성일 12-04-27 18:29본문
수정할 파일 : list.skin.php 파일
lib/common.lib.php 의
=$list[$i][datetime2]?>-아래로 변경
$wr_datetime = explode(" ", $list[$i][wr_datetime]);
$wr_date = explode("-", $wr_datetime[0]);
$wr_time = explode(":", $wr_datetime[1]);
$wr_timestamp = mktime($wr_time[0], $wr_time[1], $wr_time[2], $wr_date[1], $wr_date[2], $wr_date[0]);
$cur = $g4['server_time'] - $wr_timestamp;
if($cur > 3600 && $cur < 86400) {
$cur_time[$i] = (int)($cur / 3600); // 1시간보다 크고 24시간보다 작을 때
echo $cur_time[$i]." 시간전";
} else if($cur <= 3600) { // 1시간 이하일 때
$cur_time[$i] = (int)($cur / 60);
echo $cur_time[$i]." 분전"; } else {
echo $list[$i][datetime2];
}
?>
lib/common.lib.php 의
$list['datetime2'] = $list['wr_datetime']; if ($list['datetime'] == $g4['time_ymd']) $list['datetime2'] = substr($list['datetime2'],11,5); else $list['datetime2'] = substr($list['datetime2'],5,5);- 아래로 교체
$timestamp = strtotime($list['wr_datetime']); // 글쓴날짜시간 Unix timestamp 형식
$current = $g4['server_time']; // 현재날짜시간 Unix timestamp 형식
// 1년전
if ($timestamp <= $current - 86400 * 365) {
$str = (int)(($current - $timestamp) / (86400 * 365)) . "년전";
}
else if ($timestamp <= $current - 86400 * 31) {
$str = (int)(($current - $timestamp) / (86400 * 31)) . "개월전";
}
else if ($timestamp <= $current - 86400 * 1) {
$str = (int)(($current - $timestamp) / 86400) . "일전";
}
else if ($timestamp <= $current - 3600 * 1) {
$str = (int)(($current - $timestamp) / 3600) . "시간전";
}
else if ($timestamp <= $current - 60 * 1) {
$str = (int)(($current - $timestamp) / 60) . "분전";
}
else {
$str = (int)($current - $timestamp) . "초전";
}
$list['datetime2'] = $str;
댓글목록
등록된 댓글이 없습니다.







