Time::__get()

Proxy for missing properties.

Table of Contents
  1. Description
  2. Example

Description

Time::__get(string $key): mixed;

This method will be called when a public property is not available on class Time. By default, this method will first try to find an existing public method and call it with empty argument. If a virtual method is available and its value is a string containing at least one character %, then it will be passed to the call of Time::i() with the first argument being the value of the virtual method. If the virtual method’s value is a callable function, it will respond in the usual way.

Example

// Create a date/time format for `en` and `id` locale
Time::_('en', '%A, %B %d, %Y');
Time::_('id', '%A, %d %B %Y');

// Create a date/time format for `ru` locale with the usual way
Time::_('ru', function () {
    return $this->i('%d.%m.%y');
});

$time = new Time;

$asdf = $time->asdf; // Returns `null` because property `asdf` does not exist
$year = $time->year; // Returns `$time->year()` because method `year()` does exist

$en = $time->en; // Returns `'Monday, June 01, 2026'`
$id = $time->id; // Returns `'Monday, 01 June 2026'`
$ru = $time->ru; // Returns `'01.06.26'`

Time::__get()

Proxy for missing properties.

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.