Documentation

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

HALFHOUR

mixed $HALFHOUR = 1800

SECOND

mixed $SECOND = 1

Properties

$time

public mixed $time

$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
mixed

fromString()

从字符串建立Time Init by String time 中文格式: ?年?月?日 ?时?分 英文格式: Y-m-d H:s

public static fromString( $time : string ) : Time
Parameters
$time : string
Return values
Time

AmOrPm()

获取时间是上午还是下午

public AmOrPm( ) : string
Return values
string

thisDay()

获取当天开始 The beginning of current day

public thisDay( ) : Time
Return values
Time

today()

获取到当天时间戳 The beginning timestamp of current day

public today( ) : int
Return values
int

lastDay()

获取前一天 The beginning of last day (yesterday)

public lastDay( ) : Time
Return values
Time

yesterday()

获取前一天时间戳 The beginning timestamp of yesterday

public yesterday( ) : int
Return values
int

nextDay()

获取后一天 The beginning of next day (tomorrow)

public nextDay( ) : Time
Return values
Time

tomorrow()

获取后一天时间戳 The beginning timestamp of next day

public tomorrow( ) : int
Return values
int

thisMonth()

获取当月开始 The beginning of current month

public thisMonth( ) : Time
Return values
Time

lastMonth()

获取上个月的开始时间 The beginning of last month

public lastMonth( ) : Time
Return values
Time

nextMonth()

获取下个月开始时间 The beginning of next month

public nextMonth( ) : Time
Return values
Time

thisYear()

当前年度开端 The beginning of current year

public thisYear( ) : Time
Return values
Time

nextYear()

下一年度开端 The beginning of next year

public nextYear( ) : Time
Return values
Time

weekday()

获取对应的周几

public weekday( ) : int
Return values
int

date()

获取对应的日期

public date( ) : int
Return values
int

month()

获取对应的月份

public month( ) : int
Return values
int

year()

获取对应的年份

public year( ) : int
Return values
int

isYesterday()

检测是否昨天

public isYesterday( ) : bool
Return values
bool

isBeforeToday()

是否昨天之前

public isBeforeToday( ) : bool
Return values
bool

isBeforeDays()

是否N天之前

public isBeforeDays( $countOfDays : int ) : bool
Parameters
$countOfDays : int
Return values
bool

formatOutput()

根据预设格式输出 Output by preset format

public formatOutput( [ $format : string = TimeFormatEnum::LITE_TIME ] ) : string
Parameters
$format : string = TimeFormatEnum::LITE_TIME
Return values
string

customOutput()

特定格式输出 Output by Specific format

public customOutput( [ $StringFormat : string = "Y-m-d H:s" ] ) : string
Parameters
$StringFormat : string = "Y-m-d H:s"
Return values
string

humanityOutput()

人性化输出 User-friendly output

public humanityOutput( ) : string
Return values
string

ISO8601()

输出ISO8601格式

public static ISO8601( $timeStamp : ) : string
Parameters
$timeStamp :
Return values
string

durationToString()

将数字时长转换为文字输出

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
string

hoursToDuration()

将字符串时分转换为秒数 Convert string hours and minutes to seconds duration

public static hoursToDuration( $timeString : ) : int
Parameters
$timeString :
Return values
int

Search results