Time::i()
Returns the date/time formatted according to the given pattern.
Table of Contents
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().
| Pattern | Description | Example |
|---|---|---|
%a | An abbreviated textual representation of the day. | Sun through Sat |
%A | A full textual representation of the day. | Sunday through Saturday |
%d | Two-digit day of the month (with leading zeros). | 01 to 31 |
%u | ISO-8601 numeric representation of the day of the week. | 1 (for Monday) though 7 (for Sunday) |
%w | Numeric representation of the day of the week. | 0 (for Sunday) through 6 (for Saturday) |
%b | Abbreviated month name, based on the locale. | Jan through Dec |
%B | Full month name, based on the locale. | January through December |
%m | Two digit representation of the month. | 01 (for January) through 12 (for December) |
%y | Two digit representation of the year. | 09 for 2009, 79 for 1979 |
%Y | Four digit representation for the year. | 2038 |
%H | Two digit representation of the hour in 24-hour format. | 00 through 23 |
%I | Two digit representation of the hour in 12-hour format. | 01 through 12 |
%M | Two digit representation of the minute. | 00 through 59 |
%p | Upper-case AM or PM based on the given time. | AM for 00:31, PM for 22:23 |
%P | Lower-case am or pm based on the given time. | am for 00:31, pm for 22:23 |
%r | Same as %I:%M:%S %p | 09:34:17 PM for 21:34:17 |
%R | Same as %H:%M | 00:35 for 12:35 AM, 16:44 for 4:44 PM |
%S | Two digit representation of the second. | 00 through 59 |
%T | Same as %H:%M:%S | 21:34:17 for 09:34:17 PM |
%X | Preferred time representation based on locale, without the date. | 03:59:16 or 15:59:16 |
%c | Preferred date and time stamp based on locale. | Tue Feb 5 00:45:10 2009 for February 5, 2009 at 12:45:10 AM |
%D | Same as %m/%d/%y | 02/05/09 for February 5, 2009 |
%F | Same as %Y-%m-%d | 2009-02-05 for February 5, 2009 |
%s | Unix Epoch Time timestamp (same as the time() function). | 305815200 for September 10, 1979 08:40:00 AM |
%x | Preferred date representation based on locale, without the time. | 02/05/09 for February 5, 2009 |
%n | A new-line character (\n) | ~ |
%t | A tab character (\t) | ~ |
%% | A literal percentage character (%) | ~ |
Time::_()
The dynamic method initiator.
Time::__call()
Proxy for missing methods.
Time::__callStatic()
Proxy for missing static methods.
Time::__construct()
The constructor.
Time::__get()
Proxy for missing properties.
Time::__invoke()
Proxy for the current object, called as a function.
Time::__serialize()
Provides data to be serialized.
Time::__toString()
Proxy for the current object, casted as a string.
Time::__unserialize()
Converts the serialized data back to its object.
Time::date()
Returns the day of the month.
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::from()
Object instantiator.
Time::hour()
Returns the hour number.
Time::i()
Returns the date/time formatted according to the given pattern.
Time::minute()
Returns the minute number.
Time::month()
Returns the month number, or the month name.
Time::name()
Returns the date/time format as a valid file name.
Time::second()
Returns the second number.
Time::to()
Converts current date/time zone to other date/time zone.
Time::year()
Returns the year number.