Mecha CMS

Date and time.

$date->format()

Format date input using native PHP date formatter.

2.0.02.2.0
$date->format(string $format = DATE_WISE);

Example:

$date = (new Date('2019-09-18 16:01:23'))->format('c');

Result:

$date = '2019-09-18T16:01:23+07:00';

Common date formats:

FormatDescriptionExample
dDay of the month, 2 digits with leading zeros.01 to 31
DA textual representation of a day, three letters.Mon through Sun
jDay of the month without leading zeros.1 to 31
lA full textual representation of the day of the week.Sunday through Saturday
FA full textual representation of a month.January through December
mNumeric representation of a month, with leading zeros.01 through 12
MA short textual representation of a month, three letters.Jan through Dec
nNumeric representation of a month, without leading zeros.1 through 12
tNumber of days in the given month.28 through 31
YA full numeric representation of a year, 4 digits.1999 or 2003
yA two digit representation of a year.99 or 03
aLowercase ‘ante meridiem’ and ‘post meridiem’.am or pm
AUppercase ‘ante meridiem’ and ‘post meridiem’.AM or PM
g12-hour format of an hour without leading zeros.1 through 12
G24-hour format of an hour without leading zeros.0 through 23
h12-hour format of an hour with leading zeros.01 through 12
H24-hour format of an hour with leading zeros.00 through 23
iMinutes with leading zeros.00 to 59
sSeconds, with leading zeros.00 through 59
uMicroseconds.654321
vMilliseconds.654
cISO 8601 date.2004-02-12T15:19:21+00:00
rRFC 2822 formatted date.Thu, 21 Dec 2000 16:01:07 +0200
USeconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Read more about date formatting pattern here.