PHP & MySQL Date Format Reference

Title PHP PHP example MySQL MySQL example Notes
date($format, [$timestamp]) DATE_FORMAT(date, format)

Day & Date

Day of month with leading zero d 26 %d 26
Day of month without leading zero j 26 %e 26
Day of month with english ordinal suffix jS 26th %D 26th
Day name l Wednesday %W Wednesday
Day name abbreviated D Wed %a Wed
Day number in current week w 3 %w 3 0-Sunday, 6-Saturday
Day number in current year z 115 %j 116 PHP 0-365, MySQL 001-366

Month

Month of year with leading zero m 04 %m 04
Month of year without leading zero n 4 %c 4
Month name F April %M April
Month name abbreviated M Apr %b Apr

Year

Year Y 2017 %Y 2017
Year abbreviated y 17 %y 17

Hour

24 Hour with leading zero H 14 %H 14
24 Hour without leading zero G 14 %k 14
12 Hour with leading zero h 02 %h 02 %I also works in MySQL
12 Hour without leading zero g 2 %l 2
AM or PM A PM %p PM 'a' can also be used in php for lowercase result.

Minute

Minute with leading zero i 36 %i 36

Second

Seconds with leading zero s 00 %s 00 %S also works in MySQL

Other

Microseconds u 000000 %f 000000
Leap year L 0 '1' if leap year, '0' if not. No MySql alternative.
Documentation php.net - date() mysql.com - date_format()