*หัดอ่านบ้าง สมาชิกที่มาโปรโมทเว็บ หรือ บริการ กรุณาตั้งกระทู้ให้ถูกหมวดด้วย ไม่ต้องเนียน เว็บบอร์ดมีคนดูแล ห้าม เว็บการพนัน ลบอย่างเดียว



ผู้เขียน หัวข้อ: Relative Dates แสดงเวลาแบบ , วินาทีที่แล้ว , นาทีที่แล้ว , ชั่วโมงที่แล้ว smf  (อ่าน 6376 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

กุมภาพันธ์ 20, 2016, 03:41:10
อ่าน 6376 ครั้ง

CoolhostPlus

  • *****
  • Information ออฟไลน์
  • เริ่มโตขึ้น
  • เจ้าของเว็บ
  • กระทู้: 106
  • คะแนน : 10001
    • ดูรายละเอียด
    • www.coolhostplus.net
Relative Dates แสดงเวลาแบบ , วินาทีที่แล้ว , นาทีที่แล้ว , ชั่วโมงที่แล้ว smf

เมื่อเราตั้งกระทู้ใหม่ มันก็จะนับเป็น 1 วินาที ขึ้นไป เรื่อย ๆ

วิธ๊ทำตามนี้ได้เลย


./Sources/Subs.php

ค้นหา
อ้างถึง
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
         return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);

แก้ไขเป็น
อ้างถึง
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
      {
         // SMF has room for relative dates, no?
         if ($modSettings['todayMod'] == 3 && (empty($modSettings['enable_rt_xml']) && !isset($_REQUEST['xml']) || !empty($modSettings['enable_rt_xml']) && !isset($_REQUEST['xml'])))
         {
            // Determine the relative dates
            $seconds = $nowtime - $time;
            $minutes = floor($seconds / 60);
            $hours = floor($minutes / 60);

            // Numbers need language strings, too
            if ($seconds > -1)
            {
               if ($hours > 0 && $minutes > 59)
                  $retVal = $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']) . '  ' . $txt['ago'];
               elseif ($minutes > 0 && $seconds > 59)
                  $retVal = $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']) . '  ' . $txt['ago'];
               else
                  $retVal = $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']) . '  ' . $txt['ago'];
            }
            // Time is in the future so rework : P
            else
            {
               $seconds = $time - $nowtime;
               $minutes = floor($seconds / 60);
               $hours = floor($minutes / 60);
               if ($hours > 0 && $minutes > 59)
                  $retVal = $txt['in'] . '  ' . $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']);
               elseif ($minutes > 0 && $seconds > 59)
                  $retVal = $txt['in'] . '  ' . $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']);
               else
                  $retVal = $txt['in'] . '  ' . $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']);
            }
         }
         // Defaults FTW!
         else
            $retVal = $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);

         return $retVal;
      }


./Sources/ManageSettings.php

ค้นหา
อ้างถึง
, $txt['yesterday_today']


เพิ่มต่อที่หา
โค๊ด: [Select]
, $txt['relative_today']


ในส่วนของไฟล์ภาษา  ./Themes/default/languages/ไฟล์ภาษาของเว็บท่าน.php

อ้างถึง
$txt['hours'] = 'hours';
$txt['minutes'] = 'minutes';
$txt['seconds'] = 'seconds';
$txt['hour'] = 'hour';
$txt['minute'] = 'minute';
$txt['second'] = 'second';
$txt['ago'] = 'ago';
$txt['in'] = 'in';
$txt['relative_today'] = 'Today with relative times';

เสร็จแล้ว



Mod Name: Relative Dates
Created By: live627
Type: Theme Enhancements
Latest Version: 1.2
Compatible With: 1.1.11, 1.1.13, 1.1.15, 1.1.16, 2.0, 2.0.1, 2.0.2

credit Mod
http://custom.simplemachines.org/mods/index.php?mod=2432



Read more : http://www.justusers.net/forum/index.php?topic=10106.0