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 09 %d 09
Day of month without leading zero j 9 %e 9
Day of month with english ordinal suffix jS 9th %D 9th
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 251 %j 252 PHP 0-365, MySQL 001-366

Month

Month of year with leading zero m 09 %m 09
Month of year without leading zero n 9 %c 9
Month name F September %M September
Month name abbreviated M Sep %b Sep

Year

Year Y 2026 %Y 2026
Year abbreviated y 26 %y 26

Hour

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

Minute

Minute with leading zero i 39 %i 39

Second

Seconds with leading zero s 27 %s 27 %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()