PHP 클래스 Jyxo\Time\Time

Internally uses a \DateTime object. Initialization is possible using almost any date/time format (unix timestamp, SQL form, ...). Requires the Gettext PHP extension or any other implementation of the _(string) translation function.
저자: Jaroslav Hanslík
저자: Jan Kolibač
저자: Roman Řáha
저자: Martin Šamšula
저자: Ondřej Nešpor
상속: implements Serializable
파일 보기 프로젝트 열기: jyxo/php 1 사용 예제들

공개 메소드들

메소드 설명
__call ( string $method, array $args ) : mixed Calls a method directly on the internal \DateTime object.
__construct ( string | integer | Time | DateTime $time, string | DateTimeZone $timeZone = null ) Constructor.
__get ( string $name ) : mixed Returns date/time in the requested format.
__toString ( ) : string Returns date/time in the unix timestamp format.
createFromFormat ( string $format, string $time ) : self Creates an instance using a date/time definition in the given format.
format ( string $format, string | DateTimeZone $timeZone = null ) : string Returns date/time in the given format with months and days translated.
formatAsInterval ( boolean $useTense = true, string | DateTimeZone $timeZone = null ) : string Function for formatting time differences into human readable forms.
formatExtended ( string $dateFormat = 'j. F Y', string $timeFormat = 'G:i', string | DateTimeZone $timeZone = null ) : string Returns date/time in the form of:
get ( string | integer | Time | DateTime $time, string | DateTimeZone $timeZone = null ) : self Helper function for creating an instance with the given date/time.
getTimeZone ( ) : DateTimeZone Returns the actual time zone.
hasHappened ( ) : boolean Checks if the date/time already happened.
minus ( integer | string $interval ) : self Returns a new date/time object and adds with the given interval subtracted.
now ( ) : self Returns an instance with the current date/time.
plus ( integer | string $interval ) : self Returns a new date/time object and adds with the given interval added.
serialize ( ) : string Object serialization.
setTimeZone ( string | DateTimeZone $timeZone ) : self Sets a new time zone.
truncate ( string $unit ) : self Returns a new instance with date/time truncated to the given unit.
unserialize ( string $serialized ) Object deserialization.

보호된 메소드들

메소드 설명
createTimeZone ( string | DateTimeZone $definition ) : DateTimeZone Creates a \DateTimeZone object from a time zone definition
revertOriginalTimeZone ( ) : self Reverts the original time zone.
setTemporaryTimeZone ( string | DateTimeZone $timeZone ) Sets a time zone temporarily.

메소드 상세

__call() 공개 메소드

Calls a method directly on the internal \DateTime object.
public __call ( string $method, array $args ) : mixed
$method string Method name
$args array Method arguments
리턴 mixed

__construct() 공개 메소드

Creates an instance and initializes the internal date/time representation.
public __construct ( string | integer | Time | DateTime $time, string | DateTimeZone $timeZone = null )
$time string | integer | Time | DateTime Date/time definition
$timeZone string | DateTimeZone Time zone definition

__get() 공개 메소드

Returns date/time in the requested format.
public __get ( string $name ) : mixed
$name string Format name
리턴 mixed

__toString() 공개 메소드

Returns date/time in the unix timestamp format.
public __toString ( ) : string
리턴 string Returns empty string if the stored date/time has no valid UT representation

createFromFormat() 공개 정적인 메소드

Creates an instance using a date/time definition in the given format.
public static createFromFormat ( string $format, string $time ) : self
$format string Date/time format
$time string Date/time definition
리턴 self

createTimeZone() 보호된 메소드

Creates a \DateTimeZone object from a time zone definition
protected createTimeZone ( string | DateTimeZone $definition ) : DateTimeZone
$definition string | DateTimeZone Time zone definition
리턴 DateTimeZone

format() 공개 메소드

Returns date/time in the given format with months and days translated.
public format ( string $format, string | DateTimeZone $timeZone = null ) : string
$format string Requested format
$timeZone string | DateTimeZone Result time zone definition
리턴 string

formatAsInterval() 공개 메소드

$t < 10 seconds = Now 10 seconds <= $t < 60 seconds 1 minute <= $t < 1 hour 1 hour <= $t < 24 hours 1 day <= $t < 7 days 1 week <= $t < 4 weeks 1 month <= $t < 12 months 1 year <= $t < n years
public formatAsInterval ( boolean $useTense = true, string | DateTimeZone $timeZone = null ) : string
$useTense boolean Defines if declension should be used
$timeZone string | DateTimeZone Result time zone definition
리턴 string

formatExtended() 공개 메소드

Today at 10:00 Yesterday at 10:00 Friday at 10:00 21. March 2009 at 10:00
public formatExtended ( string $dateFormat = 'j. F Y', string $timeFormat = 'G:i', string | DateTimeZone $timeZone = null ) : string
$dateFormat string Date format
$timeFormat string Time format
$timeZone string | DateTimeZone Result time zone definition
리턴 string

get() 공개 정적인 메소드

Useful for one-time usage.
public static get ( string | integer | Time | DateTime $time, string | DateTimeZone $timeZone = null ) : self
$time string | integer | Time | DateTime Date/time definition
$timeZone string | DateTimeZone Time zone definition
리턴 self

getTimeZone() 공개 메소드

Returns the actual time zone.
public getTimeZone ( ) : DateTimeZone
리턴 DateTimeZone

hasHappened() 공개 메소드

Compares the internal date/time with the current local time of the appropriate time zone.
public hasHappened ( ) : boolean
리턴 boolean

minus() 공개 메소드

Returns a new date/time object and adds with the given interval subtracted.
public minus ( integer | string $interval ) : self
$interval integer | string Number of seconds or a string compatible with the strtotime() function
리턴 self

now() 공개 정적인 메소드

Returns an instance with the current date/time.
public static now ( ) : self
리턴 self

plus() 공개 메소드

Returns a new date/time object and adds with the given interval added.
public plus ( integer | string $interval ) : self
$interval integer | string Number of seconds or a string compatible with the strtotime() function
리턴 self

revertOriginalTimeZone() 보호된 메소드

Reverts the original time zone.
protected revertOriginalTimeZone ( ) : self
리턴 self

serialize() 공개 메소드

Object serialization.
public serialize ( ) : string
리턴 string

setTemporaryTimeZone() 보호된 메소드

Sets a time zone temporarily.
protected setTemporaryTimeZone ( string | DateTimeZone $timeZone )
$timeZone string | DateTimeZone Temporary time zone definition

setTimeZone() 공개 메소드

Sets a new time zone.
public setTimeZone ( string | DateTimeZone $timeZone ) : self
$timeZone string | DateTimeZone The new time zone
리턴 self

truncate() 공개 메소드

Returns a new instance with date/time truncated to the given unit.
public truncate ( string $unit ) : self
$unit string Unit to truncate the date/time to
리턴 self

unserialize() 공개 메소드

Object deserialization.
public unserialize ( string $serialized )
$serialized string Serialized data