This commit is contained in:
me committed 2026-07-23 15:29:13 +07:00
commit 9ec08a3e44
36 files changed
+2790

No files matched your search

+91
View File
@@ -0,0 +1,91 @@
<?php
namespace Nightmare;
class Date
{
/**
* @return int
*/
public static function now()
{
return time();
}
/**
* @param int $day
* @return int
*/
public static function start_day($day)
{
return mktime(00, 00, 00, (int) date('n'), $day);
}
/**
* @param int $month
* @return int
*/
public static function start_month($month)
{
return mktime(00, 00, 00, $month);
}
/**
* @return int
*/
public static function start_year()
{
return 0;
}
/**
* @return string
*/
public static function current_day()
{
return date('d');
}
/**
* @return string
*/
public static function current_month()
{
return date('m');
}
/**
* @return string
*/
public static function current_year()
{
return date('Y');
}
/**
* @param int $time
* @return string
*/
public static function display_ago($time)
{
$times = time() - $time;
if ($times < 1) {
$t = 'Vừa xong';
} elseif ($times < 60) {
$t = $times . ' giây trước';
} elseif ($times < 3600) {
$t = round($times / 60) . ' phút trước';
} elseif ($times < 86400) {
$t = round($times / 3600) . ' giờ trước';
} elseif ($times < 2_592_000) {
$t = round($times / 86400) . ' ngày trước';
} elseif ($times < 31_536_000) {
$t = round($times / 2_592_000) . ' tháng trước';
} else {
$t = round($times / 31_536_000) . ' năm trước';
}
return $t;
}
}