Dates

Phuture\Coherence\Type\Dates

class Dates extends FluentClass implements Dateable

A fluent, chainable wrapper around the Dates utility class for date and time manipulation.

Each method delegates to the corresponding static method on \Phuture\Coherence\Dates, stores the resulting DateTimeImmutable internally, and returns $this to enable method chaining. Retrieve the final DateTimeImmutable by calling get() or toDateTimeImmutable(), then use the static Dates class for formatting or inspection.

Example:

 1use Phuture\Coherence\Dates;
 2
 3$result = Dates::of('2026-04-21 14:30:00')
 4    ->addDays(10)
 5    ->startOfDay()
 6    ->get();
 7// DateTimeImmutable for '2026-05-01 00:00:00'
 8
 9$formatted = Dates::toDateTime(
10    Dates::of('2026-12-25', 'America/New_York')
11        ->addHours(9)
12        ->get()
13);
14// '2026-12-25 09:00:00'

Methods

addDays()

public function addDays(int $days): self

Adds a number of days to the wrapped date/time value.

Parameter Type Description
$days int The number of days to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addDays()

addHours()

public function addHours(int $hours): self

Adds a number of hours to the wrapped date/time value.

Parameter Type Description
$hours int The number of hours to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addHours()

addMinutes()

public function addMinutes(int $minutes): self

Adds a number of minutes to the wrapped date/time value.

Parameter Type Description
$minutes int The number of minutes to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addMinutes()

addMonths()

public function addMonths(int $months): self

Adds a number of months to the wrapped date/time value.

Parameter Type Description
$months int The number of months to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addMonths()

addSeconds()

public function addSeconds(int $seconds): self

Adds a number of seconds to the wrapped date/time value.

Parameter Type Description
$seconds int The number of seconds to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addSeconds()

addWeeks()

public function addWeeks(int $weeks): self

Adds a number of weeks to the wrapped date/time value.

Parameter Type Description
$weeks int The number of weeks to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addWeeks()

addYears()

public function addYears(int $years): self

Adds a number of years to the wrapped date/time value.

Parameter Type Description
$years int The number of years to add

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::addYears()

endOfDay()

public function endOfDay(): self

Moves the wrapped date/time to 23:59:59 on the same calendar day.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::endOfDay()

endOfMonth()

public function endOfMonth(): self

Moves the wrapped date/time to the last day of the same month at 23:59:59.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::endOfMonth()

endOfWeek()

public function endOfWeek(): self

Moves the wrapped date/time to Sunday 23:59:59 of the same ISO week.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::endOfWeek()

endOfYear()

public function endOfYear(): self

Moves the wrapped date/time to December 31st of the same year at 23:59:59.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::endOfYear()

fromRelative()

public function fromRelative(string $expression): self

Parses a relative date expression and replaces the wrapped date with the result.

Parameter Type Description
$expression string A relative date expression (e.g. '+2 days', 'in 3 hours')

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::fromRelative()

getTimezone()

public function getTimezone(): string

Returns the timezone identifier of the wrapped date/time value.

Returns string — The timezone identifier string (e.g. 'Europe/Paris')

See also

  • \Phuture\Coherence\Dates::getTimezone()

removeDays()

public function removeDays(int $days): self

Removes a number of days from the wrapped date/time value.

Parameter Type Description
$days int The number of days to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeDays()

removeHours()

public function removeHours(int $hours): self

Removes a number of hours from the wrapped date/time value.

Parameter Type Description
$hours int The number of hours to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeHours()

removeMinutes()

public function removeMinutes(int $minutes): self

Removes a number of minutes from the wrapped date/time value.

Parameter Type Description
$minutes int The number of minutes to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeMinutes()

removeMonths()

public function removeMonths(int $months): self

Removes a number of months from the wrapped date/time value.

Parameter Type Description
$months int The number of months to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeMonths()

removeSeconds()

public function removeSeconds(int $seconds): self

Removes a number of seconds from the wrapped date/time value.

Parameter Type Description
$seconds int The number of seconds to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeSeconds()

removeWeeks()

public function removeWeeks(int $weeks): self

Removes a number of weeks from the wrapped date/time value.

Parameter Type Description
$weeks int The number of weeks to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeWeeks()

removeYears()

public function removeYears(int $years): self

Removes a number of years from the wrapped date/time value.

Parameter Type Description
$years int The number of years to remove (must be >= 0)

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::removeYears()

startOfDay()

public function startOfDay(): self

Moves the wrapped date/time to midnight (00:00:00) on the same calendar day.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::startOfDay()

startOfMonth()

public function startOfMonth(): self

Moves the wrapped date/time to the first day of the same month at 00:00:00.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::startOfMonth()

startOfWeek()

public function startOfWeek(): self

Moves the wrapped date/time to Monday 00:00:00 of the same ISO week.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::startOfWeek()

startOfYear()

public function startOfYear(): self

Moves the wrapped date/time to January 1st of the same year at 00:00:00.

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::startOfYear()

toDate()

public function toDate(): string

Returns the date portion of the wrapped date/time as a Y-m-d string.

Returns string — The date portion formatted as 'Y-m-d'

See also

  • \Phuture\Coherence\Dates::toDate()

toDateTime()

public function toDateTime(): string

Returns the wrapped date/time as a combined date and time string.

Returns string — The date and time formatted as 'Y-m-d H:i:s'

See also

  • \Phuture\Coherence\Dates::toDateTime()

toDateTimeImmutable()

public function toDateTimeImmutable(): DateTimeImmutable

Returns the wrapped DateTimeImmutable value.

Returns DateTimeImmutable — The wrapped date and time value

toIso8601()

public function toIso8601(): string

Returns the wrapped date/time formatted as an ISO 8601 string.

Returns string — The date and time formatted according to ISO 8601

See also

  • \Phuture\Coherence\Dates::toIso8601()

toRelative()

public function toRelative(DateTimeImmutable|string|null $comparedTo = null): string

Returns a human-readable string describing how far the wrapped date is from a reference point.

Parameter Type Description
$comparedTo `DateTimeImmutable string

Returns string — A human-readable relative time string (e.g. '2 days ago', 'in 3 hours')

See also

  • \Phuture\Coherence\Dates::toRelative()

toRfc1036()

public function toRfc1036(): string

Returns the wrapped date/time formatted as an RFC 1036 string.

Returns string — The date and time formatted according to RFC 1036

See also

  • \Phuture\Coherence\Dates::toRfc1036()

toRfc1123()

public function toRfc1123(): string

Returns the wrapped date/time formatted as an RFC 1123 string.

Returns string — The date and time formatted according to RFC 1123

See also

  • \Phuture\Coherence\Dates::toRfc1123()

toRfc2822()

public function toRfc2822(): string

Returns the wrapped date/time formatted as an RFC 2822 string.

Returns string — The date and time formatted according to RFC 2822

See also

  • \Phuture\Coherence\Dates::toRfc2822()

toRfc7231()

public function toRfc7231(): string

Returns the wrapped date/time formatted as an RFC 7231 string (IMF-fixdate).

Returns string — The date and time formatted according to RFC 7231

See also

  • \Phuture\Coherence\Dates::toRfc7231()

toRfc822()

public function toRfc822(): string

Returns the wrapped date/time formatted as an RFC 822 string.

Returns string — The date and time formatted according to RFC 822

See also

  • \Phuture\Coherence\Dates::toRfc822()

toRfc850()

public function toRfc850(): string

Returns the wrapped date/time formatted as an RFC 850 string.

Returns string — The date and time formatted according to RFC 850

See also

  • \Phuture\Coherence\Dates::toRfc850()

toTime()

public function toTime(): string

Returns the time portion of the wrapped date/time as an H:i:s string.

Returns string — The time portion formatted as 'H:i:s'

See also

  • \Phuture\Coherence\Dates::toTime()

toTimestamp()

public function toTimestamp(): int

Returns the Unix timestamp representation of a date/time value.

Returns int — The number of seconds since the Unix epoch

See also

  • \Phuture\Coherence\Dates::toTimestamp()

toTimezone()

public function toTimezone(string $timezone): self

Converts the wrapped date/time to a different timezone.

Parameter Type Description
$timezone string A valid PHP timezone identifier (e.g. 'America/New_York')

Returns self — Returns the current instance for method chaining

See also

  • \Phuture\Coherence\Dates::toTimezone()

toW3c()

public function toW3c(): string

Returns the wrapped date/time formatted as a W3C string.

Returns string — The date and time formatted according to the W3C standard

See also

  • \Phuture\Coherence\Dates::toW3c()