Time::i()

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

Table of Contents
  1. Description
  2. Example
  3. Patterns

Description

Time::i(string $pattern = '%Y-%m-%d %T'): string;

Unlike Time::format(), this method will return a formatted date/time where the day and month names will be affected by the current locale’s translation 1.

Example

$time = new Time;

echo $time->i('%Y/%m/%d'); // Returns `'2026/02/03'`

Patterns

The following is a list of date/time patterns that you will probably use frequently. You can read the complete list of it on the official documentation of strftime(), which is deprecated as of PHP version 8.1 but not on Mecha because I have added those patterns back by converting the given pattern to the standard format used in method Time::format().

PatternDescriptionExample
%aAn abbreviated textual representation of the day.Sun through Sat
%AA full textual representation of the day.Sunday through Saturday
%dTwo-digit day of the month (with leading zeros).01 to 31
%uISO-8601 numeric representation of the day of the week.1 (for Monday) though 7 (for Sunday)
%wNumeric representation of the day of the week.0 (for Sunday) through 6 (for Saturday)
%bAbbreviated month name, based on the locale.Jan through Dec
%BFull month name, based on the locale.January through December
%mTwo digit representation of the month.01 (for January) through 12 (for December)
%yTwo digit representation of the year.09 for 2009, 79 for 1979
%YFour digit representation for the year.2038
%HTwo digit representation of the hour in 24-hour format.00 through 23
%ITwo digit representation of the hour in 12-hour format.01 through 12
%MTwo digit representation of the minute.00 through 59
%pUpper-case AM or PM based on the given time.AM for 00:31, PM for 22:23
%PLower-case am or pm based on the given time.am for 00:31, pm for 22:23
%rSame as %I:%M:%S %p09:34:17 PM for 21:34:17
%RSame as %H:%M00:35 for 12:35 AM, 16:44 for 4:44 PM
%STwo digit representation of the second.00 through 59
%TSame as %H:%M:%S21:34:17 for 09:34:17 PM
%XPreferred time representation based on locale, without the date.03:59:16 or 15:59:16
%cPreferred date and time stamp based on locale.Tue Feb 5 00:45:10 2009 for February 5, 2009 at 12:45:10 AM
%DSame as %m/%d/%y02/05/09 for February 5, 2009
%FSame as %Y-%m-%d2009-02-05 for February 5, 2009
%sUnix Epoch Time timestamp (same as the time() function).305815200 for September 10, 1979 08:40:00 AM
%xPreferred date representation based on locale, without the time.02/05/09 for February 5, 2009
%nA new-line character (\n)~
%tA tab character (\t)~
%%A literal percentage character (%)~

  1. This requires a translation extension such as Language

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.