Time::hour()

Returns the hour number.

Table of Contents
  1. Description
  2. Example

Description

Time::hour(?int $type = 24): string;

This method returns the hour number, 2 digits with leading zeros. Set the type to 12 to return 12-hours number format.

Example

$time = new Time('2022-12-08 22:00:00');

echo $time->hour(); // Returns `'22'`
echo $time->hour(12); // Returns `'10'`

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::hour()

Returns the hour number.

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.