Time::__construct()

The constructor.

Table of Contents
  1. Description
  2. Example

Description

Time::__construct(?int|string $value = null): self;

This method will be called when you instantiate a Time class.

Example

$time = new Time; // Now
$time = new Time('+1 day'); // Relative time format
$time = new Time('2026-02-03 07:28:07');
$time = new Time('2026-02-03-07-28-07'); // Non-standard format, probably comes from a file name
$time = new Time(1770078487); // Unix time stamp

Time::__construct()

The constructor.

Time::day()

Returns the day number of the week, or the day name.

Time::format()

Returns the date/time formatted according to the given format.

Time::i()

Returns the date/time formatted according to the given pattern.

Time::name()

Returns the date/time format as a valid file name.

Time::to()

Converts current date/time zone to other date/time zone.