\fastDate

日期时间处理类

Summary

Methods
Properties
Constants
offset()
span()
human()
unixtime()
No public properties found
YEAR
MONTH
WEEK
DAY
HOUR
MINUTE
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

YEAR

YEAR = 31536000

MONTH

MONTH = 2592000

WEEK

WEEK = 604800

DAY

DAY = 86400

HOUR

HOUR = 3600

MINUTE

MINUTE = 60

Methods

offset()

offset(string  $remote, string  $local = NULL, mixed  $now = NULL) : integer

计算两个时区间相差的时长,单位为秒

$seconds = self::offset('America/Chicago', 'GMT');

[!!] A list of time zones that PHP supports can be found at http://php.net/timezones.

Parameters

string $remote

timezone that to find the offset of

string $local

timezone used as the baseline

mixed $now

UNIX timestamp or date string

Returns

integer

span()

span(integer  $remote, integer  $local = NULL, string  $output = 'years,months,weeks,days,hours,minutes,seconds') : string

计算两个时间戳之间相差的时间

$span = self::span(60, 182, 'minutes,seconds'); // array('minutes' => 2, 'seconds' => 2) $span = self::span(60, 182, 'minutes'); // 2

Parameters

integer $remote

timestamp to find the span of

integer $local

timestamp to use as the baseline

string $output

formatting string

Returns

string —

when only a single output is requested

human()

human(  $remote, mixed  $local = null) : string

格式化 UNIX 时间戳为人易读的字符串

Parameters

$remote
mixed $local

本地时间

Returns

string —

格式化的日期字符串

unixtime()

unixtime(string  $type = 'day', integer  $offset, string  $position = 'begin', integer  $year = null, integer  $month = null, integer  $day = null, integer  $hour = null, integer  $minute = null) : integer

获取一个基于时间偏移的Unix时间戳

Parameters

string $type

时间类型,默认为day,可选minute,hour,day,week,month,quarter,year

integer $offset

时间偏移量 默认为0,正数表示当前type之后,负数表示当前type之前

string $position

时间的开始或结束,默认为begin,可选前(begin,start,first,front),end

integer $year

基准年,默认为null,即以当前年为基准

integer $month

基准月,默认为null,即以当前月为基准

integer $day

基准天,默认为null,即以当前天为基准

integer $hour

基准小时,默认为null,即以当前年小时基准

integer $minute

基准分钟,默认为null,即以当前分钟为基准

Returns

integer —

处理后的Unix时间戳