ICanBoogie/DateTime 2.0.x
  • Namespace
  • Class

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 integer
# getTimestamp( )

Returns

integer
abstract public DateTimeZone
# getTimezone( )

Returns

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

Parameters

$year
$month
$day

Returns

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

Parameters

$hour
$minute
$second

Returns

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

Inheritdoc

public static
# none( $timezone = 'utc' )

Inheritdoc

public static
# right_now( )

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 string
# __toString( )

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 string
# jsonSerialize( )

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 = ICanBoogie\DateTime\DateTimeLocalizer::DEFAULT_LOCALE )

Inheritdoc

Magic methods summary

public string
# format_as_atom( )

format_as_atom() Formats the instance according to ATOM.

format_as_atom() Formats the instance according to ATOM.

Returns

string
public string
# format_as_cookie( )

format_as_cookie() Formats the instance according to COOKIE.

format_as_cookie() Formats the instance according to COOKIE.

Returns

string
public string
# format_as_iso8601( )

format_as_iso8601() Formats the instance according to ISO8601.

format_as_iso8601() Formats the instance according to ISO8601.

Returns

string
public string
# format_as_rfc822( )

format_as_rfc822() Formats the instance according to RFC822.

format_as_rfc822() Formats the instance according to RFC822.

Returns

string
public string
# format_as_rfc850( )

format_as_rfc850() Formats the instance according to RFC850.

format_as_rfc850() Formats the instance according to RFC850.

Returns

string
public string
# format_as_rfc1036( )

format_as_rfc1036() Formats the instance according to RFC1036.

format_as_rfc1036() Formats the instance according to RFC1036.

Returns

string
public string
# format_as_rfc1123( )

format_as_rfc1123() Formats the instance according to RFC1123.

format_as_rfc1123() Formats the instance according to RFC1123.

Returns

string
public string
# format_as_rfc2822( )

format_as_rfc2822() Formats the instance according to RFC2822.

format_as_rfc2822() Formats the instance according to RFC2822.

Returns

string
public string
# format_as_rfc3339( )

format_as_rfc3339() Formats the instance according to RFC3339.

format_as_rfc3339() Formats the instance according to RFC3339.

Returns

string
public string
# format_as_rss( )

format_as_rss() Formats the instance according to RSS.

format_as_rss() Formats the instance according to RSS.

Returns

string
public string
# format_as_w3c( )

format_as_w3c() Formats the instance according to W3C.

format_as_w3c() Formats the instance according to W3C.

Returns

string
public string
# format_as_db( )

format_as_db() Formats the instance according to DB.

format_as_db() Formats the instance according to DB.

Returns

string
public string
# format_as_number( )

format_as_number() Formats the instance according to NUMBER.

format_as_number() Formats the instance according to NUMBER.

Returns

string
public string
# format_as_date( )

format_as_date() Formats the instance according to DATE.

format_as_date() Formats the instance according to DATE.

Returns

string
public string
# format_as_time( )

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 integer $year

Year.

public read-only integer $month

Month of the year.

public read-only integer $day

Day of the month.

public read-only integer $hour

Hour of the day.

public read-only integer $minute

Minute of the hour.

public read-only integer $second

Second of the minute.

public read-only boolean $is_empty

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

public read-only string $as_iso8601

The instance formatted according to ISO8601.

ICanBoogie/DateTime 2.0.x API documentation generated by ApiGen