PHP 클래스 Scalr_Util_DateTime

파일 보기 프로젝트 열기: scalr/scalr 1 사용 예제들

공개 메소드들

메소드 설명
convertDateTime ( DateTime | string | integer $value, string $timezone, string $format = 'M j, Y H:i:s' ) : string Converts Time according to timezone parameter.
convertTimeZone ( DateTime $dt, $remoteTz = NULL )
convertTz ( DateTime | string | integer $value, string $format = 'M j, Y H:i:s' ) : string Converts Time according to timezone settings of current user.
convertTzFromUTC ( DateTime | string | integer $value, string $format = 'M j, Y H:i:s' ) : string Converts Time according to timezone settings of current user from UTC date.
correctTime ( integer $time, float $tz_offset = null ) : integer Correct time with current timezone offset
findTimezoneByOffset ( $offset )
getDateTimeDiff ( $dateTime1, $dateTime2, boolean $humanReadable = true ) : string | integer Calculates difference in seconds between two dates.
getFuzzyTime ( integer | string $time, integer $tz_offset = null ) : string Gets a slightly more fuzzy time string. such as: yesterday at 3:51pm
getFuzzyTimeString ( $value )
getHumanReadableTimeout ( integer | string $time, boolean $show_secs = true ) : string Converts a Unix timestamp or date/time string to a human-readable format, such as '1 day, 2 hours, 42 mins, and 52 secs'
getIncrescentTimeInterval ( $value, $currentTime = null ) : string Formats a time interval depending on the size according to: - just now - interval < 1 min - 2 min ago - interval < 30 mins - 3:17 AM - today - Yesterday, 3:17 AM - yesterday - Jan. 10, 7:12 AM - current year - Jan. 10,2015, 7:12 AM - less than the current year
getTimezones ( boolean $returnOffset = false ) : array
yearweek ( string $date ) : number Gets the week of the year in the same way as MYSQL's YEARWEEK(date, 0) MODE 0

메소드 상세

convertDateTime() 공개 정적인 메소드

Converts Time according to timezone parameter.
public static convertDateTime ( DateTime | string | integer $value, string $timezone, string $format = 'M j, Y H:i:s' ) : string
$value DateTime | string | integer DateTime object or Unix Timestamp or string that represents time.
$timezone string TimeZone
$format string Format
리턴 string Returns updated time in given format.

convertTimeZone() 공개 정적인 메소드

public static convertTimeZone ( DateTime $dt, $remoteTz = NULL )
$dt DateTime

convertTz() 공개 정적인 메소드

Converts Time according to timezone settings of current user.
public static convertTz ( DateTime | string | integer $value, string $format = 'M j, Y H:i:s' ) : string
$value DateTime | string | integer DateTime object or Unix Timestamp or string that represents time.
$format string Format
리턴 string Returns updated time in given format.

convertTzFromUTC() 공개 정적인 메소드

Converts Time according to timezone settings of current user from UTC date.
public static convertTzFromUTC ( DateTime | string | integer $value, string $format = 'M j, Y H:i:s' ) : string
$value DateTime | string | integer DateTime object or Unix Timestamp or string that represents time.
$format string Format
리턴 string Returns updated time in given format.

correctTime() 공개 정적인 메소드

Correct time with current timezone offset
public static correctTime ( integer $time, float $tz_offset = null ) : integer
$time integer Time to convert
$tz_offset float timezone offset in hours
리턴 integer Returns unix timestamp

findTimezoneByOffset() 공개 정적인 메소드

public static findTimezoneByOffset ( $offset )

getDateTimeDiff() 공개 정적인 메소드

Calculates difference in seconds between two dates.
public static getDateTimeDiff ( $dateTime1, $dateTime2, boolean $humanReadable = true ) : string | integer
$humanReadable boolean Return number of seconds or human readable string
리턴 string | integer Returns difference between dates.

getFuzzyTime() 공개 정적인 메소드

Gets a slightly more fuzzy time string. such as: yesterday at 3:51pm
public static getFuzzyTime ( integer | string $time, integer $tz_offset = null ) : string
$time integer | string Time
$tz_offset integer optional A timezone offset
리턴 string

getFuzzyTimeString() 공개 정적인 메소드

public static getFuzzyTimeString ( $value )

getHumanReadableTimeout() 공개 정적인 메소드

Based on the word_time() function from PG+ (http://pgplus.ewtoo.org)
public static getHumanReadableTimeout ( integer | string $time, boolean $show_secs = true ) : string
$time integer | string Timeout
$show_secs boolean optional Should it show the seconds
리턴 string Returns human readable timeout

getIncrescentTimeInterval() 공개 정적인 메소드

Formats a time interval depending on the size according to: - just now - interval < 1 min - 2 min ago - interval < 30 mins - 3:17 AM - today - Yesterday, 3:17 AM - yesterday - Jan. 10, 7:12 AM - current year - Jan. 10,2015, 7:12 AM - less than the current year
public static getIncrescentTimeInterval ( $value, $currentTime = null ) : string
리턴 string

getTimezones() 공개 정적인 메소드

public static getTimezones ( boolean $returnOffset = false ) : array
$returnOffset boolean optional If true return object [timezone] = GMT offset, otherwise return array of timezones
리턴 array

yearweek() 공개 정적인 메소드

Gets the week of the year in the same way as MYSQL's YEARWEEK(date, 0) MODE 0
public static yearweek ( string $date ) : number
$date string The date YYYY-MM-DD
리턴 number Returns yearweek, for example: 201402