\Imi\UtilDateTime

日期时间工具类

Summary

Methods
Properties
Constants
getSecondsByInterval()
getYesterday()
getTomorrow()
getNextWeek()
getLastWeek()
getWeekOfMonth()
getMonthWeekCount()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getSecondsByInterval()

getSecondsByInterval(\DateInterval  $dateInterval) : integer

将一个 \DateInterval,与当前时间进行计算,获取秒数

Parameters

\DateInterval $dateInterval

Returns

integer

getYesterday()

getYesterday(string|null  $format = null, integer|null  $timestamp = null) : string|integer

获取昨天的时间

可传入 $format 格式化,不传则返回时间戳 可传入 $timestamp 指定时间戳,不传则取当前时间

Parameters

string|null $format
integer|null $timestamp

Returns

string|integer

getTomorrow()

getTomorrow(string|null  $format = null, integer|null  $timestamp = null) : string|integer

获取明天的时间

可传入 $format 格式化,不传则返回时间戳 可传入 $timestamp 指定时间戳,不传则取当前时间

Parameters

string|null $format
integer|null $timestamp

Returns

string|integer

getNextWeek()

getNextWeek(integer|null  $weekNo = null, string|null  $format = null, integer|null  $timestamp = null) : void

获取下周的时间

可传入 $weekNo 指定周几,周一到周日为1-7,不传则取时间戳对应周几 可传入 $format 格式化,不传则返回时间戳 可传入 $timestamp 指定时间戳,不传则取当前时间

Parameters

integer|null $weekNo
string|null $format
integer|null $timestamp

getLastWeek()

getLastWeek(integer|null  $weekNo = null, string|null  $format = null, integer|null  $timestamp = null) : void

获取上周的时间

可传入 $weekNo 指定周几,周一到周日为1-7,不传则取时间戳对应周几 可传入 $format 格式化,不传则返回时间戳 可传入 $timestamp 指定时间戳,不传则取当前时间

Parameters

integer|null $weekNo
string|null $format
integer|null $timestamp

getWeekOfMonth()

getWeekOfMonth(integer|null  $timestamp = null) : void

获取一个月中的第几周

可传入 $weekNo 指定周几,周一到周日为1-7,不传则取时间戳对应周几 可传入 $format 格式化,不传则返回时间戳 可传入 $timestamp 指定时间戳,不传则取当前时间

Parameters

integer|null $timestamp

getMonthWeekCount()

getMonthWeekCount(integer  $year, integer  $month) : integer

获取该月份一共有多少周

返回值可能是 4 或 5

Parameters

integer $year
integer $month

Returns

integer