Date and Time
Nette\Utils\DateTime is a class extends native DateTime.
Installation:
All examples assume the following class alias is defined:
static from(string|int|\DateTimeInterface $time): DateTime
Creates a DateTime object from a string, UNIX timestamp, or other DateTimeInterface object. Throws an Exception
if the date and time are
not valid.
static fromParts(int $year, int $month, int $day, int $hour=0, int $minute=0, float $second=0.0): DateTime
Creates DateTime object or throws an Nette\InvalidArgumentException
exception if the date and time are
not valid.
static createFromFormat(string $format, string $time, ?string|\DateTimeZone $timezone=null): DateTime|false
Extends DateTime::createFromFormat() with the ability to specify a timezone as a string.
modifyClone(string
$modify=''
): static
Creates a copy with a modified time.
__toString(): string
Returns the date and time in the format Y-m-d H:i:s
.
Implements JsonSerializable
Returns the date and time in ISO 8601 format, which is used in JavaScript, for example.