Time
in
时间 Time
Table of Contents
CENTURY | 3155692600 | |
---|---|---|
YEAR | 31556926 | |
THIRTY | 2592000 | |
WEEK | 604800 | |
DAY | 86400 | |
HOUR | 3600 | |
HALFHOUR | 1800 | |
MIN | 60 | |
SECOND | 1 | |
$time | ||
$now | ||
$lang | ||
__construct() | mixed | |
now() | 单例 | Time |
fromString() | 从字符串建立Time Init by String time 中文格式: ?年?月?日 ?时?分 英文格式: Y-m-d H:s | Time |
AmOrPm() | 获取时间是上午还是下午 | string |
thisDay() | 获取当天开始 The beginning of current day | Time |
today() | 获取到当天时间戳 The beginning timestamp of current day | int |
lastDay() | 获取前一天 The beginning of last day (yesterday) | Time |
yesterday() | 获取前一天时间戳 The beginning timestamp of yesterday | int |
nextDay() | 获取后一天 The beginning of next day (tomorrow) | Time |
tomorrow() | 获取后一天时间戳 The beginning timestamp of next day | int |
thisMonth() | 获取当月开始 The beginning of current month | Time |
lastMonth() | 获取上个月的开始时间 The beginning of last month | Time |
nextMonth() | 获取下个月开始时间 The beginning of next month | Time |
thisYear() | 当前年度开端 The beginning of current year | Time |
nextYear() | 下一年度开端 The beginning of next year | Time |
weekday() | 获取对应的周几 | int |
date() | 获取对应的日期 | int |
month() | 获取对应的月份 | int |
year() | 获取对应的年份 | int |
isYesterday() | 检测是否昨天 | bool |
isBeforeToday() | 是否昨天之前 | bool |
isBeforeDays() | 是否N天之前 | bool |
formatOutput() | 根据预设格式输出 Output by preset format | string |
customOutput() | 特定格式输出 Output by Specific format | string |
humanityOutput() | 人性化输出 User-friendly output | string |
ISO8601() | 输出ISO8601格式 | string |
durationToString() | 将数字时长转换为文字输出 | string |
hoursToDuration() | 将字符串时分转换为秒数 Convert string hours and minutes to seconds duration | int |
Constants
CENTURY
mixed
$CENTURY
= 3155692600
YEAR
mixed
$YEAR
= 31556926
THIRTY
mixed
$THIRTY
= 2592000
WEEK
mixed
$WEEK
= 604800
DAY
mixed
$DAY
= 86400
HOUR
mixed
$HOUR
= 3600
HALFHOUR
mixed
$HALFHOUR
= 1800
MIN
mixed
$MIN
= 60
SECOND
mixed
$SECOND
= 1
Properties
$time
public
mixed
$time
$now
public
mixed
$now
$lang
public
mixed
$lang
Methods
__construct()
public
__construct(
[ $specifiedTime :
int|null
= null ]
[, $lang :
string|null
= null ]
)
: mixed
Parameters
- $specifiedTime : int|null = null
- $lang : string|null = null
Return values
mixednow()
单例
public
static now(
)
: Time
Return values
TimefromString()
从字符串建立Time Init by String time 中文格式: ?年?月?日 ?时?分 英文格式: Y-m-d H:s
public
static fromString(
$time :
string
)
: Time
Parameters
- $time : string
Return values
TimeAmOrPm()
获取时间是上午还是下午
public
AmOrPm(
)
: string
Return values
stringthisDay()
获取当天开始 The beginning of current day
public
thisDay(
)
: Time
Return values
Timetoday()
获取到当天时间戳 The beginning timestamp of current day
public
today(
)
: int
Return values
intlastDay()
获取前一天 The beginning of last day (yesterday)
public
lastDay(
)
: Time
Return values
Timeyesterday()
获取前一天时间戳 The beginning timestamp of yesterday
public
yesterday(
)
: int
Return values
intnextDay()
获取后一天 The beginning of next day (tomorrow)
public
nextDay(
)
: Time
Return values
Timetomorrow()
获取后一天时间戳 The beginning timestamp of next day
public
tomorrow(
)
: int
Return values
intthisMonth()
获取当月开始 The beginning of current month
public
thisMonth(
)
: Time
Return values
TimelastMonth()
获取上个月的开始时间 The beginning of last month
public
lastMonth(
)
: Time
Return values
TimenextMonth()
获取下个月开始时间 The beginning of next month
public
nextMonth(
)
: Time
Return values
TimethisYear()
当前年度开端 The beginning of current year
public
thisYear(
)
: Time
Return values
TimenextYear()
下一年度开端 The beginning of next year
public
nextYear(
)
: Time
Return values
Timeweekday()
获取对应的周几
public
weekday(
)
: int
Return values
intdate()
获取对应的日期
public
date(
)
: int
Return values
intmonth()
获取对应的月份
public
month(
)
: int
Return values
intyear()
获取对应的年份
public
year(
)
: int
Return values
intisYesterday()
检测是否昨天
public
isYesterday(
)
: bool
Return values
boolisBeforeToday()
是否昨天之前
public
isBeforeToday(
)
: bool
Return values
boolisBeforeDays()
是否N天之前
public
isBeforeDays(
$countOfDays :
int
)
: bool
Parameters
- $countOfDays : int
Return values
boolformatOutput()
根据预设格式输出 Output by preset format
public
formatOutput(
[ $format :
string
= TimeFormatEnum::LITE_TIME ]
)
: string
Parameters
- $format : string = TimeFormatEnum::LITE_TIME
Return values
stringcustomOutput()
特定格式输出 Output by Specific format
public
customOutput(
[ $StringFormat :
string
= "Y-m-d H:s" ]
)
: string
Parameters
- $StringFormat : string = "Y-m-d H:s"
Return values
stringhumanityOutput()
人性化输出 User-friendly output
public
humanityOutput(
)
: string
Return values
stringISO8601()
输出ISO8601格式
public
static ISO8601(
$timeStamp :
)
: string
Parameters
Return values
stringdurationToString()
将数字时长转换为文字输出
public
static durationToString(
$duration :
int
[, $format :
string
= '{{year}}-{{month}}-{{day}} {{hour}}:{{minute}} {{second}}' ]
)
: string
Parameters
- $duration : int
- $format : string = '{{year}}-{{month}}-{{day}} {{hour}}:{{minute}} {{second}}'
( With Mixer syntax )
Return values
stringhoursToDuration()
将字符串时分转换为秒数 Convert string hours and minutes to seconds duration
public
static hoursToDuration(
$timeString :
)
: int