Name
DATE_FORMAT()
Synopsis
DATE_FORMAT(date
,format
)
Returns the date
value formatted
according to the format
string. Table D-2 shows the specifiers
that can be used in the format
string. Note
that the %
character is required
before each specifier, as shown. This code returns the given date and
time as âWednesday May 4th 2016 03:02 AMâ:
SELECT DATE_FORMAT('2016-05-04 03:02:01', '%W %M %D %Y %h:%i %p');
Specifier | Description |
| Abbreviated weekday name (SunâSat) |
| Abbreviated month name (JanâDec) |
| Month, numeric (0â12) |
| Day of the month with English suffix (0th, 1st, 2nd, 3rd, ...) |
| Day of the month, numeric (00â31) |
| Day of the month, numeric (0â31) |
| Microseconds (000000â999999) |
| Hour (00â23) |
| Hour (01â12) |
| Hour (01â12) |
| Minutes, numeric (00â59) |
| Day of year (001â366) |
| Hour (0â23) |
| Hour (1â12) |
| Month name (JanuaryâDecember) |
| Month, numeric (00â12) |
| AM or PM |
| Time, 12-hour (hh:mm:ss followed by AM or PM) |
| Seconds (00â59) |
| Seconds (00â59) |
| Time, 24-hour (hh:mm:ss) |
| Week (00â53), where Sunday is the first day of the week |
| Week (00â53), where Monday is the first day of the week |
| Week (01â53), where
Sunday is the first day of the week; used with |
| Week (01â53), where
Monday is the first day of the week; used with |
| Weekday name (SundayâSaturday) |
| Day of the week (0=Sundayâ6=Saturday) |
| Year for the week where Sunday is the first day of the week, numeric, ... |
Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.