<?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 getMicroTime($dateTime = null)
    {
        $time = microtime(true);
        if ($dateTime && is_string($dateTime)) {
            $time = strtotime($dateTime);
        }
        if ($dateTime && is_int($dateTime)) {
            $time = $dateTime;
        }
        $time *= 1000;

        return ceil($time);
    }
}
