Date class

Framework\Date\Date

Class Date.

Extends DateTime

Implements: DateTimeInterface, JsonSerializable, Stringable

Defined in libraries/date/src/Date.php

Constants #

DATETIME
-

Properties #

$language
-

$language

protected \Framework\Language\Language $language

Methods #

__construct()
-
__toString()
-
createFromFormat()
Parse a string into a new static object according to the specified format.
createFromImmutable()
-
getLanguage()
-
humanize()
-
jsonSerialize()
-
setLanguage()
-

__construct()

public final function __construct(string $datetime = 'now', ?DateTimeZone $timezone = NULL, ?\Framework\Language\Language $language = NULL)
Parameters
  • string $datetime
  • ?DateTimeZone $timezone
  • ?\Framework\Language\Language $language

__toString()

public function __toString(): string
Returns string

createFromFormat()

public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = NULL): static|false

Parse a string into a new static object according to the specified format.

Parameters
  • string $format - Format accepted by date()
  • string $datetime - A string representing the time
  • ?DateTimeZone $timezone - A DateTimeZone object representing the desired time zone
Returns static|false
throws
Exception Emits Exception in case of an error

createFromImmutable()

public static function createFromImmutable(DateTimeImmutable $object): static
Parameters
  • DateTimeImmutable $object
Returns static
throws
Exception Emits Exception in case of an error

getLanguage()

public function getLanguage(): \Framework\Language\Language
Returns \Framework\Language\Language

humanize()

public function humanize(): string
Returns string

jsonSerialize()

public function jsonSerialize(): string
Returns string

setLanguage()

public function setLanguage(\Framework\Language\Language $language): static
Parameters
  • \Framework\Language\Language $language
Returns static

Inherited methods #