ICanBoogie/DateTime 2.0.x
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • DateTime

Classes

  • DateTimeLocalizer
  • ImmutableDateTime
  • MutableDateTime
  • TimeZone
  • TimeZoneLocation

Interfaces

  • DateTime

Interface DateTime

Interface for ICanBoogie's mutable and immutable date time classes.

ICanBoogie\DateTime implements DateTimeInterface

Direct known implementers

ICanBoogie\ImmutableDateTime, ICanBoogie\MutableDateTime

Namespace: ICanBoogie
Located at DateTime.php

Methods summary

public static ICanBoogie\DateTime
# from( mixed $source, mixed $timezone = null )

Creates a ICanBoogie\DateTime instance from a source.

Creates a ICanBoogie\DateTime instance from a source.

<?php

use ICanBoogie\ImmutableDateTime as DateTime;

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

Parameters

$source
$timezone

The time zone to use to create the time. The value is ignored if the source is an instance of \DateTime.

Returns

ICanBoogie\DateTime
public static ICanBoogie\DateTime
# none( DateTimeZone|string $timezone = 'utc' )

Returns an instance representing an empty date ("0000-00-00").

Returns an instance representing an empty date ("0000-00-00").

<?php

use ICanBoogie\ImmutableDateTime as DateTime;

$d = DateTime::none();
$d->is_empty;                      // true
$d->timezone->name;                // "UTC"

$d = DateTime::none('Asia/Tokyo');
$d->is_empty;                      // true
$d->timezone->name;                // "Asia/Tokio"

Parameters

$timezone

The time zone in which the empty date is created. Defaults to "UTC".

Returns

ICanBoogie\DateTime
public static ICanBoogie\DateTime
# now( )

Returns an instance with the current local time and the local time zone.

Returns an instance with the current local time and the local time zone.

Note: Subsequent calls return equal times, event if they are minutes apart. now actually refers to the REQUEST_TIME or, if it is now available, to the first time the method was invoked.

Returns

ICanBoogie\DateTime
public static ICanBoogie\DateTime
# right_now( )

Returns an instance with the current local time and the local time zone.

Returns an instance with the current local time and the local time zone.

Note: Subsequent calls may return different times.

Returns

ICanBoogie\DateTime
public ICanBoogie\DateTime
# modify( string $modify )

Alters the timestamp.

Alters the timestamp.

Parameters

$modify

Returns

ICanBoogie\DateTime
public ICanBoogie\DateTime
# change( array $options, boolean $cascade = false )

Modifies the properties of the instance according to the options.

Modifies the properties of the instance according to the options.

The following properties can be updated: $year, $month, $day, $hour, $minute and $second.

Note: Values exceeding ranges are added to their parent values.

<?php

use ICanBoogie\ImmutableDateTime as DateTime;

$time = new DateTime('now');
$time->change([ 'year' => 2000, 'second' => 0 ]);

Parameters

$options
$cascade

If true, time options (hour, minute, second) reset cascading, so if only the hour is passed, then minute and second is set to 0. If the hour and minute is passed, then second is set to 0.

Returns

ICanBoogie\DateTime
$this
public ICanBoogie\DateTime
# with( array $options, boolean $cascade = false )

Returns a new instance with changes properties.

Returns a new instance with changes properties.

Parameters

$options
$cascade

Returns

ICanBoogie\DateTime
public mixed
# localize( string $locale = 'en' )

Returns a localized instance.

Returns a localized instance.

Parameters

$locale

Returns

mixed

Throws

LogicException
if the instance cannot be localized.

Methods inherited from DateTimeInterface

__wakeup(), diff(), format(), getOffset(), getTimestamp(), getTimezone()

Constants summary

string DB

DB (example: 2013-02-03 20:59:03)

DB (example: 2013-02-03 20:59:03)

# 'Y-m-d H:i:s'
string NUMBER

Number (example: 20130203205903)

Number (example: 20130203205903)

# 'YmdHis'
string DATE

Date (example: 2013-02-03)

Date (example: 2013-02-03)

# 'Y-m-d'
string TIME

Time (example: 20:59:03)

Time (example: 20:59:03)

# 'H:i:s'
ICanBoogie/DateTime 2.0.x API documentation generated by ApiGen