- 优化时间门面

v6 v6.0.98
Chaim 4 years ago
parent b07f497475
commit 127d4b02c2

@ -1,3 +1,6 @@
## v6.0.98 / 2020-07-25
- 优化时间门面
## v6.0.97 / 2020-07-23
- 增加小数门面

@ -26,7 +26,7 @@ use think\db\exception\DbException;
/**
* 定义当前版本
*/
const VERSION = '6.0.97';
const VERSION = '6.0.98';
if (!function_exists('get_ip_info')) {
/**

@ -36,8 +36,9 @@ use think\Facade;
* @method static string getUDate() 当前时间戳
* @method static string getTimeDifference(string $end_time, string $start_time) 计算两个时间差
* @method static string dateToTimestamp(string $date) 将指定日期转换为时间戳
* @method static string dateRear(string $format = "Y-m-d H:i:s", int $mun = 10) f获取某个时间之后的时间
* @method static string dateBefore(string $format = "Y-m-d H:i:s", int $mun = 10) 获取某个时间之前的时间
* @method static string timestampToDate(int $time, string $format = "Y-m-d H:i:s") 将指定时间戳转换为日期
* @method static string dateRear(string $format = "Y-m-d H:i:s", int $mun = 10) 在当前时间之后的时间
* @method static string dateBefore(string $format = "Y-m-d H:i:s", int $mun = 10) 在当前时间之前的时间
* @method static bool checkIsBetweenTime(string $start, string $end) 判断当前的时分是否在指定的时间段内
*/
class Times extends Facade

@ -71,7 +71,7 @@ class Times
{
date_default_timezone_set('Asia/Shanghai');
$end_time = strtotime($end_time);
$start_time = $start_time == '' ? strtotime(self::getData('Y-m-d H:i:s')) : strtotime($start_time);
$start_time = $start_time == '' ? time() : strtotime($start_time);
return $end_time - $start_time;
}
@ -87,27 +87,39 @@ class Times
}
/**
* 获取某个时间之后的时间
* 将指定时间戳转换为日期
* @param string $format
* @param int $time
* @return false|string
*/
public function timestampToDate(int $time, string $format = "Y-m-d H:i:s")
{
date_default_timezone_set('Asia/Shanghai');
return date($format, $time);
}
/**
* 在当前时间之前的时间
* @param string $format 格式
* @param int $mun 多少分钟
* @param int $mun 多少
* @return false|string
*/
public function dateRear(string $format = "Y-m-d H:i:s", int $mun = 10)
public function dateBefore(string $format = "Y-m-d H:i:s", int $mun = 60)
{
date_default_timezone_set('Asia/Shanghai');
return date($format, strtotime(self::getData()) + $mun);
return date($format, time() - $mun);
}
/**
* 获取某个时间之前的时间
* 在当前时间之后的时间
* @param string $format 格式
* @param int $mun 多少分钟
* @param int $mun 多少
* @return false|string
*/
public function dateBefore(string $format = "Y-m-d H:i:s", int $mun = 10)
public function dateRear(string $format = "Y-m-d H:i:s", int $mun = 60)
{
date_default_timezone_set('Asia/Shanghai');
return date($format, strtotime(self::getData()) - $mun);
return date($format, time() + $mun);
}

Loading…
Cancel
Save