[Share] Code hiện thị thời gian post bài giống facebook cho JohnCMS

ID Topic: 33057 • Có 930 lượt xem
Hình đại diện của thành viên
#1 - @434595
20/02/2016 23:40
Chèn code sau vào incfiles/classes/functions.php
Mã:
<?php
//time post bai
public static function gio($var) {

$time time();
$jun round(($time-$var)/60);
$shift = (self::$system_set['timeshift'] + self::$user_set['timeshift']) * 3600;
if (
date('Y'$var) == date('Y'time())) {
if(
$jun 1) {
$jun='Vừa xong';
}
if(
$jun >= && $jun 60){
$jun "$jun phút trước";
}
if(
$jun >= 60 && $jun 1440){
$jun round($jun/60);
$jun "$jun giờ trước";
}

if(
$jun >= 1440 && $jun 2880){
$jun "Hôm qua";
}
if(
$jun >= 2880 && $jun 10080){
$day round($jun/60/24);
$jun "$day ngày trước";
}
}
if(
$jun 10080){
$jun date("d/m/Y - H:i"$var $shift);
}
return 
$jun;
}


 public static function 
display_date($var)
    {
        
$shift = (self::$system_set['timeshift'] + self::$user_set['timeshift']) * 3600;
        if (
date('Y'$var) == date('Y'time())) {
            if (
date('z'$var $shift) == date('z'time() + $shift))
                return 
self::$lng['today'] . ', ' date("H:i"$var $shift);
            if (
date('z'$var $shift) == date('z'time() + $shift) - 1)
                return 
self::$lng['yesterday'] . ', ' date("H:i"$var $shift);
        }

        return 
date("d.m.Y / H:i"$var $shift);
    }
?>

Xong lưu lại.
Chúc thành công!
(Nokia c2-01)
PM|Trích|Like|Sửa|Xóa|Báo cáo|Cảnh cáo
_______________
Facebook
Website
Trả lời nhanh

Chủ đề tương tự