mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 22:50:44 +00:00
46 lines
986 B
PHP
46 lines
986 B
PHP
<?php
|
|
|
|
namespace App\Utils;
|
|
|
|
class DateTimeUtils
|
|
{
|
|
/**
|
|
* 今天7点到明天7点算作今天
|
|
*/
|
|
public static function getToday()
|
|
{
|
|
$time = time();
|
|
$inventoryTime = strtotime(date('Y-m-d 07:00:00'));
|
|
if ($time < $inventoryTime) {
|
|
$time = strtotime('-1 day');
|
|
}
|
|
|
|
return date('Y-m-d', $time);
|
|
}
|
|
|
|
public static function getNextDay()
|
|
{
|
|
$time = time();
|
|
$inventoryTime = strtotime(date('Y-m-d 07:00:00'));
|
|
if ($time > $inventoryTime) {
|
|
$time = strtotime('+1 day');
|
|
}
|
|
|
|
return date('Y-m-d', $time);
|
|
}
|
|
|
|
public static function getMicroTime($dateTime = null)
|
|
{
|
|
$time = microtime(true);
|
|
if ($dateTime && is_string($dateTime)) {
|
|
$time = strtotime($dateTime);
|
|
}
|
|
if ($dateTime && is_int($dateTime)) {
|
|
$time = $dateTime;
|
|
}
|
|
$time *= 1000;
|
|
|
|
return (int)ceil($time);
|
|
}
|
|
}
|