TimeHelper
class TimeHelper
时间相关操作
Methods
标准的UNIX时间戳 获得当前格林威治时间的时间戳
检测是否是标准时间
是否是日期范围
格式化时间
自定义函数:time2string($second) 输入秒数换算成多少天/多少小时/多少分/多少秒的字符串
转换字符串形式的时间表达式为GMT时间戳
获得服务器的时区
一天的开始, 未传值代表今天
一天的结束, 未传值代表今天
格式化日期
空日期检测
datetime to timestamp
时间戳转换成 datetime 类型
精确时间间隔函数 $time 发布时间 如 1356973323 $str 输出格式 如 Y-m-d H:i:s 半年的秒数为15552000,1年为31104000,此处用半年的时间
Returns a human readable time difference from the value to the current time. Eg: 10 minutes ago
Returns 24-hour time and the day using the grammatical tense of the current time. Eg: Today at 12:49, Yesterday at 4:00 or 18 Sep 2015 at 14:33.
Converts a PHP date format to "Moment.js" format.
返回微秒数值
通过 Carbon 对象来获取格式化的时间
根据日期返回每年的周数 例如 2020-01-01 会返回 [2019,52] 周, 用于统计部分
Details
at line 21
static int
gmTime()
标准的UNIX时间戳 获得当前格林威治时间的时间戳
at line 32
static bool
isDate(string $date, string $sep = '-')
检测是否是标准时间
at line 56
static bool
isDateRange($range)
是否是日期范围
at line 70
static bool|string
datetime(int|string $time = 0, string $format = '3-3')
格式化时间
at line 109
static string
time2string(mixed $second, bool $more = false)
自定义函数:time2string($second) 输入秒数换算成多少天/多少小时/多少分/多少秒的字符串
at line 129
static bool|int|string
gmStr2Time(string $str)
转换字符串形式的时间表达式为GMT时间戳
at line 144
static float|string
serverTimezone()
获得服务器的时区
at line 158
static string
dayStart(string $date = '')
一天的开始, 未传值代表今天
at line 171
static string
dayEnd(string $date = '')
一天的结束, 未传值代表今天
at line 185
static string
format(int|string $time = 0, string $format = 'Y-m-d H:i')
格式化日期
at line 201
static bool
isEmpty(string $date)
空日期检测
at line 211
static int
datetimeToTimestamp(string $datetime)
datetime to timestamp
at line 221
static string
timestampToDatetime(string $timestamp)
时间戳转换成 datetime 类型
at line 234
static int|string
todayStart(bool|false $unix = false)
deprecated
deprecated
获取今日起始时间
at line 252
static int|string
todayEnd(bool|false $unix = false)
deprecated
deprecated
获取今日起始时间
at line 270
static false|string
tranTime(mixed $time)
精确时间间隔函数 $time 发布时间 如 1356973323 $str 输出格式 如 Y-m-d H:i:s 半年的秒数为15552000,1年为31104000,此处用半年的时间
at line 311
static string
timeSince(string|int $datetime)
Returns a human readable time difference from the value to the current time. Eg: 10 minutes ago
at line 324
static string
timeTense(mixed $datetime)
Returns 24-hour time and the day using the grammatical tense of the current time. Eg: Today at 12:49, Yesterday at 4:00 or 18 Sep 2015 at 14:33.
at line 349
static Carbon|null
makeCarbon(Carbon|DateTime|string|int $value)
Converts mixed inputs to a Carbon object.
at line 378
static string
momentFormat(string $format)
Converts a PHP date format to "Moment.js" format.
at line 431
static string
micro()
返回微秒数值
at line 444
static string
fetchFormat(Carbon|null|string $carbon, string $format = 'Y-m-d H:i:s')
通过 Carbon 对象来获取格式化的时间
at line 464
static array
week(string $date, int $start = Carbon::MONDAY)
根据日期返回每年的周数 例如 2020-01-01 会返回 [2019,52] 周, 用于统计部分