PHP Date function is used to format a local time/date.
The PHP Date() Function
Syntax :
date(string $format, timestamp) ;
The PHP date() function have 2 Parameter. Parameter format specifies the format of the timestamp. We can get second parameter timestamp using time() function.
Date Format :
The PHP date() function have three format for day, month and year as below.
d (Lowercase) - Specify the day of the month from 01 to 31.
m (Lowercase) - Specify a month from 01 to 12
y (Lowercase) - Specify a year in two digits
D (uppercase) - Specify the day of week from Sun to Sat.
M (uppercase) - Specify a month from Jan to Dec
Y (uppercase) - Specify a year in four digits
l (lowercase) - Specify the day from Sunday to Saturday.
F (uppercase) - Specify a month like April
Time Format :
We can show time in hour, minute and second format using below characters.
H - Specify 24-hour format of an hour from 00 to 23
h - Specify 12-hour format of an hour with leading zeros from 01 to 12
i - Specify Minutes with leading zeros from 00 to 59
s - Specify Seconds with leading zeros from 00 to 59
a - Lowercase a specify Ante meridiem and Post meridiem such as am or pm
A - Uppercase a specify Ante meridiem and Post meridiem such as AM or PM in uppercase.
Learn php date() function using below examples.
Comments