feat : ali
This commit is contained in:
99
app/Extend/DateUtil.php
Normal file
99
app/Extend/DateUtil.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Extend;
|
||||
|
||||
class DateUtil
|
||||
{
|
||||
public const MINUTE = 60; // 分
|
||||
public const HOUR = 3600; // 小时
|
||||
public const DAY = 86400; // 天
|
||||
public const WEEK = 604800; // 周
|
||||
public const MONTH = 2592000; // 月
|
||||
public const YEAR = 311040000; // 年
|
||||
|
||||
/**
|
||||
* 获取当前时间到今日结束的秒数
|
||||
* @return int
|
||||
*/
|
||||
static function getTodayEnds(): int
|
||||
{
|
||||
return 86400 - (time() + 8 * 3600) % 86400;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间
|
||||
* @return string
|
||||
*/
|
||||
static function getCurrentDatetime(): string
|
||||
{
|
||||
return date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取今日开始的时间
|
||||
* @return string
|
||||
*/
|
||||
static function getTodayStartDate(): string
|
||||
{
|
||||
return date("Y-m-d 00:00:00");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取今日结束的时间
|
||||
* @return string
|
||||
*/
|
||||
static function getTodayEndDate(): string
|
||||
{
|
||||
return date("Y-m-d 23:59:59");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期
|
||||
* @return string
|
||||
*/
|
||||
static function getCurrentDate(): string
|
||||
{
|
||||
return date('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某天开始的时间
|
||||
* @param int $i
|
||||
* @return string
|
||||
*/
|
||||
static function getStartDate(int $i = 1): string
|
||||
{
|
||||
return date("Y-m-d 00:00:00", strtotime("-{$i} day"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某日结束的时间
|
||||
* @param int $i
|
||||
* @return string
|
||||
*/
|
||||
static function getEndDate(int $i = 1): string
|
||||
{
|
||||
return date("Y-m-d 23:59:59", strtotime("-{$i} day"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某天前日期
|
||||
* @param int $i
|
||||
* @return string
|
||||
*/
|
||||
static function getDate(int $i = 1): string
|
||||
{
|
||||
return date('Y-m-d', strtotime("-{$i} day"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的毫秒时间戳(13位)
|
||||
* @return string
|
||||
*/
|
||||
static function getCurrentMsTime(): string
|
||||
{
|
||||
list($ms, $sec) = explode(' ', microtime());
|
||||
$msTime = (float)sprintf('%.0f', (floatval($ms) + floatval($sec)) * 1000);
|
||||
return substr($msTime,0,13);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user