时间类¶
属性 | 值 |
---|---|
命名空间 | fize\datetime |
类名 | Time |
父类 | fize\datetime\Date |
实现接口 | DateTimeInterface |
常量: |
---|
名称 | 值 | 说明 |
---|---|---|
ATOM | “Y-m-d\TH:i:sP” | |
COOKIE | “l, d-M-Y H:i:s T” | |
ISO8601 | “Y-m-d\TH:i:sO” | |
RFC822 | “D, d M y H:i:s O” | |
RFC850 | “l, d-M-y H:i:s T” | |
RFC1036 | “D, d M y H:i:s O” | |
RFC1123 | “D, d M Y H:i:s O” | |
RFC7231 | “D, d M Y H:i:s \G\M\T” | |
RFC2822 | “D, d M Y H:i:s O” | |
RFC3339 | “Y-m-d\TH:i:sP” | |
RFC3339_EXTENDED | “Y-m-d\TH:i:s.vP” | |
RSS | “D, d M Y H:i:s O” | |
W3C | “Y-m-d\TH:i:sP” |
方法: |
---|
方法名 | 说明 |
---|---|
gettimeofday() | 取得当前时间 |
gmmktime() | 取得 GMT 日期的 UNIX 时间戳 |
gmstrftime() | 根据区域设置格式化 GMT/UTC 时间/日期,返回时间是格林威治标准时(GMT)。 |
localtime() | 取得本地时间 |
microtime() | 返回当前 Unix 时间戳和微秒数 |
mktime() | 取得一个日期的 Unix 时间戳 |
strftime() | 根据区域设置格式化本地时间/日期 |
strptime() | 解析由 strftime() 生成的日期/时间 |
strtotime() | 将任何字符串的日期时间描述解析为 Unix 时间戳 |
check() | 检查由参数构成的日期的合法性。 |
parseFromFormat() | 获取根据指定格式格式化的给定日期的信息 |
parse() | 返回有关给定日期的详细信息的关联数组 |
sunInfo() | 返回一个包含日落/日出和黄昏开始/结束信息的数组 |
sunrise() | 返回给定的日期与地点的日出时间 |
sunset() | 返回给定的日期与地点的日落时间 |
getdate() | 取得日期/时间信息 |
gmdate() | 格式化一个 GMT/UTC 日期/时间 |
idate() | 将本地时间日期格式化为整数 |
常量¶
ATOM¶
修饰符: | public |
---|---|
类型: | string |
值: | “Y-m-d\TH:i:sP” |
COOKIE¶
修饰符: | public |
---|---|
类型: | string |
值: | “l, d-M-Y H:i:s T” |
ISO8601¶
修饰符: | public |
---|---|
类型: | string |
值: | “Y-m-d\TH:i:sO” |
RFC822¶
修饰符: | public |
---|---|
类型: | string |
值: | “D, d M y H:i:s O” |
RFC850¶
修饰符: | public |
---|---|
类型: | string |
值: | “l, d-M-y H:i:s T” |
RFC1036¶
修饰符: | public |
---|---|
类型: | string |
值: | “D, d M y H:i:s O” |
RFC1123¶
修饰符: | public |
---|---|
类型: | string |
值: | “D, d M Y H:i:s O” |
RFC7231¶
修饰符: | public |
---|---|
类型: | string |
值: | “D, d M Y H:i:s \G\M\T” |
RFC2822¶
修饰符: | public |
---|---|
类型: | string |
值: | “D, d M Y H:i:s O” |
RFC3339¶
修饰符: | public |
---|---|
类型: | string |
值: | “Y-m-d\TH:i:sP” |
RFC3339_EXTENDED¶
修饰符: | public |
---|---|
类型: | string |
值: | “Y-m-d\TH:i:s.vP” |
RSS¶
修饰符: | public |
---|---|
类型: | string |
值: | “D, d M Y H:i:s O” |
W3C¶
修饰符: | public |
---|---|
类型: | string |
值: | “Y-m-d\TH:i:sP” |
方法¶
gettimeofday()¶
取得当前时间
public static function gettimeofday (
bool $return_float = null
) : array|float
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 默认返回一个 array。如果 return_float 设置了则会返回一个 float。 |
gmmktime()¶
取得 GMT 日期的 UNIX 时间戳
public static function gmmktime (
int $hour = null,
int $minute = null,
int $second = null,
int $month = null,
int $day = null,
int $year = null
) : int
参数: |
|
---|
gmstrftime()¶
根据区域设置格式化 GMT/UTC 时间/日期,返回时间是格林威治标准时(GMT)。
public static function gmstrftime (
string $format,
int $timestamp = null
) : string
参数: |
|
---|
localtime()¶
取得本地时间
public static function localtime (
int $timestamp = null,
bool $is_associative = null
) : array
参数: |
|
---|
参数 `$is_associative` :
如果设为 FALSE 或未提供则返回的是普通的数字索引数组。
如果该参数设为 TRUE 则 localtime() 函数返回包含有所有从 C 的 localtime 函数调用所返回的不同单元的关联数组。
microtime()¶
返回当前 Unix 时间戳和微秒数
public static function microtime (
bool $get_as_float = null
) : mixed
参数: |
|
---|
mktime()¶
取得一个日期的 Unix 时间戳
public static function mktime (
int $hour = null,
int $minute = null,
int $second = null,
int $month = null,
int $day = null,
int $year = null
) : int
参数: |
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
strftime()¶
根据区域设置格式化本地时间/日期
public static function strftime (
string $format,
int $timestamp = null
) : string
参数: |
|
---|
strptime()¶
解析由 strftime() 生成的日期/时间
public static function strptime (
string $date,
string $format
) : array
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 失败返回false |
strtotime()¶
将任何字符串的日期时间描述解析为 Unix 时间戳
public static function strtotime (
string $time,
int $now = null
) : int
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 失败返回false |
参数 `$time` :
正确格式的说明详见 日期与时间格式。
check()¶
检查由参数构成的日期的合法性。
public static function check (
int $month,
int $day,
int $year
) : bool
参数: |
|
---|
如果每个参数都正确定义了则会被认为是有效的。
参数 `$day` :
闰年已经考虑进去了。
parseFromFormat()¶
获取根据指定格式格式化的给定日期的信息
public static function parseFromFormat (
string $format,
string $date
) : array
参数: |
|
---|
parse()¶
返回有关给定日期的详细信息的关联数组
public static function parse (
string $date
) : array
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 失败时返回false |
sunInfo()¶
返回一个包含日落/日出和黄昏开始/结束信息的数组
public static function sunInfo (
int $time,
float $latitude,
float $longitude
) : array
参数: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
sunrise()¶
返回给定的日期与地点的日出时间
public static function sunrise (
int $timestamp,
int $format = null,
float $latitude = null,
float $longitude = null,
float $zenith = null,
float $gmt_offset = null
) : mixed
参数: |
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 按指定格式 format 返回的日出时间, 或者在失败时返回 FALSE。 |
sunset()¶
返回给定的日期与地点的日落时间
public static function sunset (
int $timestamp,
int $format = null,
float $latitude = null,
float $longitude = null,
float $zenith = null,
float $gmt_offset = null
) : mixed
参数: |
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
返回值: | 按指定格式 format 返回的日出时间, 或者在失败时返回 FALSE。 |
getdate()¶
取得日期/时间信息
public static function getdate (
int $timestamp = null
) : array
参数: |
|
---|
gmdate()¶
格式化一个 GMT/UTC 日期/时间
public static function gmdate (
string $format,
int $timestamp = null
) : string
参数: |
|
||||||
---|---|---|---|---|---|---|---|
返回值: | 失败时返回false |
idate()¶
将本地时间日期格式化为整数
public static function idate (
string $format,
int $timestamp = null
) : int
参数: |
|
---|