Overview

Namespaces

  • NGS
    • Client
      • Exception
    • Converter
    • Patterns
  • PHP

Classes

  • BigDecimal
  • BigInt
  • ByteStream
  • LocalDate
  • Location
  • Money
  • Name
  • Point
  • S3
  • Timestamp
  • Utils
  • UUID
  • Overview
  • Namespace
  • Class
  • Tree

Class Timestamp

Date object with timezone

Namespace: NGS
Located at Timestamp.php
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

$timezone
string|DateTimeZone
$timezone

Returns

DateTimeZone

Throws

InvalidArgumentException
public static DateTimeZone
# getDefaultTimezone( )

Get default timezone

Get default timezone

Returns

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

InvalidArgumentException
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

InvalidArgumentException
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

$other
NGS\Timestamp
$other Instance of NGS\Timestamp
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

DateTime
Time value as DateTime instance
public NGS\LocalDate
# toLocalDate( )

Gets as \NGS\LocalDate instance

Gets as \NGS\LocalDate instance

Returns

NGS\LocalDate
Time value as NGS\LocalDate instance
Constants summary
string DEFAULT_TIMEZONE 'UTC'
#
string STRING_FORMAT 'Y-m-d\\TH:i:s.uP'
#
string FALLBACK_FORMAT 'Y-m-d\\TH:i:sP'
#
Properties summary
protected DateTime $datetime
#
API documentation generated by ApiGen 2.8.0