ICanBoogie
  • Documentation
  • API Reference
  • DateTime 2.0.x
Namespaces
  • ICanBoogie
    • DateTime
Traits
  • Readers
  • Shared

Trait Shared

Direct Known Users

ICanBoogie\ImmutableDateTime, ICanBoogie\MutableDateTime

Namespace: ICanBoogie\DateTime
Located at DateTime/Shared.php

Methods summary

abstract public getTimestamp( void ) : integer

Returns

integer
abstract public getTimezone( void ) : DateTimeZone

Returns

DateTimeZone
abstract public setDate( integer $year, integer $month, integer $day ) : DateTime|DateTimeImmutable

Parameters

$year
$month
$day

Returns

DateTime|DateTimeImmutable
abstract public setTime( integer $hour, integer $minute, integer|null $second = null ) : DateTime|DateTimeImmutable

Parameters

$hour
$minute
$second

Returns

DateTime|DateTimeImmutable
public static from( $source, $timezone = null )

Inheritdoc

public static none( $timezone = 'utc' )

Inheritdoc

public static right_now( void )

Inheritdoc

public __construct( string $time = 'now', DateTimeZone|string|null $timezone = null )

If the time zone is specified as a string a \DateTimeZone instance is created and used instead.

If the time zone is specified as a string a \DateTimeZone instance is created and used instead.

<?php

use ICanBoogie\ImmutableDateTime as DateTime;

new DateTime('2001-01-01 01:01:01', new \DateTimeZone('Europe/Paris')));
new DateTime('2001-01-01 01:01:01', 'Europe/Paris');
new DateTime;

Parameters

$time
Defaults to "now".
$timezone
public __call( $method, $arguments )

Handles the format_as_* methods.

Handles the format_as_* methods.

Throws

BadMethodCallException
in attempt to call an unsupported method.

Inheritdoc

See

format_as()
public __toString( void ) : string

Returns the datetime formatted as ISO8601.

Returns the datetime formatted as ISO8601.

Returns

string

The instance rendered as an ISO8601 string, or an empty string if the datetime is empty.

public jsonSerialize( void ) : string

Returns a ISO8601 representation of the instance.

Returns a ISO8601 representation of the instance.

Returns

string
public setTimezone( $timezone )

The timezone can be specified as a string.

The timezone can be specified as a string.

If the timezone is local the timezone returned by date_default_timezone_get() is used instead.

Inheritdoc

public format( $format )

If the instance represents an empty date and the format is DATE or DB, an empty date is returned, respectively "0000-00-00" and "0000-00-00 00:00:00". Note that the time information is discarded for DB. This only apply to DATE and DB formats. For instance RSS will return the following string: "Wed, 30 Nov -0001 00:00:00 +0000".

If the instance represents an empty date and the format is DATE or DB, an empty date is returned, respectively "0000-00-00" and "0000-00-00 00:00:00". Note that the time information is discarded for DB. This only apply to DATE and DB formats. For instance RSS will return the following string: "Wed, 30 Nov -0001 00:00:00 +0000".

Inheritdoc

public change( array $options, $cascade = false )

Inheritdoc

public localize( $locale = DateTimeLocalizer::DEFAULT_LOCALE )

Inheritdoc

Magic methods summary

public format_as_atom( void ) : string

format_as_atom() Formats the instance according to ATOM.

format_as_atom() Formats the instance according to ATOM.

Returns

string
public format_as_cookie( void ) : string

format_as_cookie() Formats the instance according to COOKIE.

format_as_cookie() Formats the instance according to COOKIE.

Returns

string
public format_as_iso8601( void ) : string

format_as_iso8601() Formats the instance according to ISO8601.

format_as_iso8601() Formats the instance according to ISO8601.

Returns

string
public format_as_rfc822( void ) : string

format_as_rfc822() Formats the instance according to RFC822.

format_as_rfc822() Formats the instance according to RFC822.

Returns

string
public format_as_rfc850( void ) : string

format_as_rfc850() Formats the instance according to RFC850.

format_as_rfc850() Formats the instance according to RFC850.

Returns

string
public format_as_rfc1036( void ) : string

format_as_rfc1036() Formats the instance according to RFC1036.

format_as_rfc1036() Formats the instance according to RFC1036.

Returns

string
public format_as_rfc1123( void ) : string

format_as_rfc1123() Formats the instance according to RFC1123.

format_as_rfc1123() Formats the instance according to RFC1123.

Returns

string
public format_as_rfc2822( void ) : string

format_as_rfc2822() Formats the instance according to RFC2822.

format_as_rfc2822() Formats the instance according to RFC2822.

Returns

string
public format_as_rfc3339( void ) : string

format_as_rfc3339() Formats the instance according to RFC3339.

format_as_rfc3339() Formats the instance according to RFC3339.

Returns

string
public format_as_rss( void ) : string

format_as_rss() Formats the instance according to RSS.

format_as_rss() Formats the instance according to RSS.

Returns

string
public format_as_w3c( void ) : string

format_as_w3c() Formats the instance according to W3C.

format_as_w3c() Formats the instance according to W3C.

Returns

string
public format_as_db( void ) : string

format_as_db() Formats the instance according to DB.

format_as_db() Formats the instance according to DB.

Returns

string
public format_as_number( void ) : string

format_as_number() Formats the instance according to NUMBER.

format_as_number() Formats the instance according to NUMBER.

Returns

string
public format_as_date( void ) : string

format_as_date() Formats the instance according to DATE.

format_as_date() Formats the instance according to DATE.

Returns

string
public format_as_time( void ) : string

format_as_time() Formats the instance according to TIME.

format_as_time() Formats the instance according to TIME.

Returns

string

Properties summary

Magic properties

public read-only $year : integer

Year.

public read-only $month : integer

Month of the year.

public read-only $day : integer

Day of the month.

public read-only $hour : integer

Hour of the day.

public read-only $minute : integer

Minute of the hour.

public read-only $second : integer

Second of the minute.

public read-only $is_empty : boolean

true if the instance represents an empty date such as "0000-00-00" or "0000-00-00 00:00:00".

public read-only $as_iso8601 : string

The instance formatted according to ISO8601.

DateTime 2.0.x – Check on GitHub – API documentation generated by ApiGen