PHP 클래스 Webiny\Component\StdLib\StdObject\DateTimeObject\DateTimeObject

Class that enables you to work with dates and time much easier.
상속: extends Webiny\Component\StdLib\StdObject\AbstractStdObject, use trait ValidatorTrait, use trait ManipulatorTrait
파일 보기 프로젝트 열기: Webiny/Framework 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$value DateTime | null

공개 메소드들

메소드 설명
__construct ( string | integer $time = "now", null | string $timezone = null ) Constructor.
__toString ( ) : mixed To string implementation.
createFromFormat ( string | integer $time, null | string $format = null ) : DateTimeObject Create a DateTimeObject from the given $time and $format.
diff ( integer | string | DateTime | DateTimeObject $time, boolean $absolute = false ) : ArrayObject
format ( string $format ) : string Return date in the given format.
getDate ( null | string $format = null ) : string Get date in full date format.
getDay ( null | string $format = null ) : string Get day based on current date.
getHours ( null | string $format = null ) : string Get hours based on current date.
getMeridiem ( null | string $format = null ) : string Get meridiem (am, pm) based on current date.
getMinutes ( ) : string Get minutes based on current date.
getMongoDate ( ) : MongoDB\BSON\UTCDatetime Get MongoDate object
getMonth ( null | string $format = null ) : string Get month based on current date.
getOffset ( ) : integer Get the offset from current timezone to the UTC timezone in seconds.
getSeconds ( ) : string Get seconds based on current date.
getTime ( null | string $format = null ) : string Return time based on current date.
getTimeAgo ( null $from = null ) : string Calculates the time passed between current date and $form (default: now).
getTimestamp ( ) : integer Get UNIX timestamp based on current date.
getTimezone ( ) : string Get the name of current timezone.
getWeek ( ) : integer Get week number based on current date.
getYear ( null | string $format = null ) : string Get year based on current date.
setFormat ( string $format ) Set the date format.
setTimezone ( string | DateTimeZone $timezone ) Set a new timezone for current date object.
val ( null $value = null ) : mixed Return, or update, current standard objects value.

비공개 메소드들

메소드 설명
buildFormatterList ( ) Reformats self::$formatters from array to ArrayObject.
createTimezone ( string | null $timezone = null ) : DateTimeZone Create a DateTimeZone object for the given $timeZone.
getDateElement ( string $dateElement, null | string $format = null ) : string Returns defined $dateElement in defined $format.
getDateObject ( ) : DateTime | null Returns current \DateTime object.
getFormatFor ( string $dateElement ) : mixed Returns format for defined $dateElement.
parseDateTimeFormat ( ) This function parses the format provided by Config and sets the default formatting for getting date information like day, month, year, etc.
validateFormatFor ( string $dateElement, string $format ) : mixed Checks if $format is a valid format for $dateElement.

메소드 상세

__construct() 공개 메소드

Set standard object value.
public __construct ( string | integer $time = "now", null | string $timezone = null )
$time string | integer A date/time string. List of available formats is explained here http://www.php.net/manual/en/datetime.formats.php
$timezone null | string Timezone in which you want to set the date. Here is a list of valid timezones: http://php.net/manual/en/timezones.php

__toString() 공개 메소드

To string implementation.
public __toString ( ) : mixed
리턴 mixed

createFromFormat() 공개 정적인 메소드

Create a DateTimeObject from the given $time and $format.
public static createFromFormat ( string | integer $time, null | string $format = null ) : DateTimeObject
$time string | integer Timestamp.
$format null | string Format in which the current timestamp is defined.
리턴 DateTimeObject

diff() 공개 메소드

public diff ( integer | string | DateTime | DateTimeObject $time, boolean $absolute = false ) : ArrayObject
$time integer | string | DateTime | DateTimeObject Date to compare to.
$absolute boolean Should the interval be forced to be positive?
리턴 Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject Instance of ArrayObject containing time units (d,m,y,h,i,s) for keys and amounts for their values.

format() 공개 메소드

Return date in the given format.
public format ( string $format ) : string
$format string A valid date format.
리턴 string A string containing the date in the given $format.

getDate() 공개 메소드

Get date in full date format.
public getDate ( null | string $format = null ) : string
$format null | string A valid date format.
리턴 string Date in full date format like ISO 8691 or RFC 2822.

getDay() 공개 메소드

Get day based on current date.
public getDay ( null | string $format = null ) : string
$format null | string A valid day format.
리턴 string Day based on current date.

getHours() 공개 메소드

Get hours based on current date.
public getHours ( null | string $format = null ) : string
$format null | string A valid hour format.
리턴 string Hours based on current date.

getMeridiem() 공개 메소드

Get meridiem (am, pm) based on current date.
public getMeridiem ( null | string $format = null ) : string
$format null | string A valid meridiem format.
리턴 string Meridiem (am, pm) based on current date.

getMinutes() 공개 메소드

Get minutes based on current date.
public getMinutes ( ) : string
리턴 string Minutes based on current date

getMongoDate() 공개 메소드

Get MongoDate object
public getMongoDate ( ) : MongoDB\BSON\UTCDatetime
리턴 MongoDB\BSON\UTCDatetime

getMonth() 공개 메소드

Get month based on current date.
public getMonth ( null | string $format = null ) : string
$format null | string A valid month format.
리턴 string Month based on current date.

getOffset() 공개 메소드

Get the offset from current timezone to the UTC timezone in seconds.
public getOffset ( ) : integer
리턴 integer The offset from current timezone to UTC in seconds.

getSeconds() 공개 메소드

Get seconds based on current date.
public getSeconds ( ) : string
리턴 string Seconds based on current date.

getTime() 공개 메소드

Return time based on current date.
public getTime ( null | string $format = null ) : string
$format null | string A valid time format.
리턴 string Time based on current date.

getTimeAgo() 공개 메소드

The output is formatted in plain words, like "4 hours ago".
public getTimeAgo ( null $from = null ) : string
$from null Timestamp from where to calculate the offset. Default is now.
리턴 string String describing the passed time. Example "4 hours ago".

getTimestamp() 공개 메소드

Get UNIX timestamp based on current date.
public getTimestamp ( ) : integer
리턴 integer UNIX timestamp based on current date

getTimezone() 공개 메소드

Get the name of current timezone.
public getTimezone ( ) : string
리턴 string The name of current timezone.

getWeek() 공개 메소드

Get week number based on current date.
public getWeek ( ) : integer
리턴 integer Wek number based on current date.

getYear() 공개 메소드

Get year based on current date.
public getYear ( null | string $format = null ) : string
$format null | string A valid year format.
리턴 string Year based on current date.

setFormat() 공개 메소드

Set the date format.
public setFormat ( string $format )
$format string Date format. These are the valid options: http://php.net/manual/en/function.date.php

setTimezone() 공개 메소드

NOTE: The current timestamp will be recalculated with the offset of current timezone and the new defined one.
public setTimezone ( string | DateTimeZone $timezone )
$timezone string | DateTimeZone Timezone to which you wish to offset. You can either pass \DateTimeZone object or a valid timezone string. For timezone string formats visit: http://php.net/manual/en/timezones.php

val() 공개 메소드

Return, or update, current standard objects value.
public val ( null $value = null ) : mixed
$value null If $value is set, value is updated and DateTimeObject is returned.
리턴 mixed

프로퍼티 상세

$value 보호되어 있는 프로퍼티

protected DateTime|null $value
리턴 DateTime | null