Class Timestamp
Date object with timezone
Methods summary
public static
DateTimeZone
|
#
setDefaultTimezone( string|DateTimeZone $timezone )
Set default timezone. New TimeStamp instances are set to default timezone
Set default timezone. New TimeStamp instances are set to default timezone
Parameters
Returns
Throws
|
public static
DateTimeZone
|
|
public
|
#
__construct( DateTime |NGS\DateTime|string|integer|float|null $value = 'now', string $pattern = NGS\Timestamp::STRING_FORMAT , string $timezone = NGS\Timestamp::DEFAULT_TIMEZONE )
Constructs a new Timestamp instance
Constructs a new Timestamp instance
Parameters
- $value
DateTime |NGS\DateTime|string|integer|float|null
$value Instance of \DateTime or \NGS\Timestamp, valid string format, timestamp
as int/float, or null for current time
- $pattern
string $pattern format in which to parse the timestamp, defaults to 'Y-m-d\\TH:i:s.uP'
- $timezone
string $timezone Set to override default timezone, string representation of a timezone,
null defaults to 'UTC'
Throws
|
public static
array
|
#
toArray( array $items, mixed $allowNullValues = false )
Constructs array of Timestamps from array of valid constructor arguments
Constructs array of Timestamps from array of valid constructor arguments
Parameters
- $items
array $items
- $allowNullValues
Returns
array
Throws
|
public
string
|
#
__toString( )
Returns time in default format 'Y-m-d\\TH:i:s.uP'
Returns time in default format 'Y-m-d\\TH:i:s.uP'
Returns
string formatted timestamp with time zone
|
public
string
|
#
format( mixed $pattern )
Returns time in default format 'Y-m-d\\TH:i:s.uP'
Returns time in default format 'Y-m-d\\TH:i:s.uP'
Returns
string formatted timestamp with time zone
|
public
|
#
equals( NGS\Timestamp $other )
Checks for equality against another Timestamp instance
Checks for equality against another Timestamp instance
Parameters
|
public
integer
|
#
toInt( )
Gets time in Unix timestamp
Gets time in Unix timestamp
Returns
integer Unix timestamp
|
public
float
|
#
toFloat( )
Gets time in Unix timestamp with microseconds
Gets time in Unix timestamp with microseconds
Returns
float Unix timestamp with microseconds
|
public
DateTime
|
#
toDateTime( )
Gets time value as Datetime instance
Gets time value as Datetime instance
Returns
|
public
NGS\LocalDate
|
#
toLocalDate( )
Gets as \NGS\LocalDate instance
Gets as \NGS\LocalDate instance
Returns
|