Mega Code Archive

 
Categories / MySQL Tutorial / Date Time Functions
 

You can optionally give FROM_UNIXTIME function a format parameter

DATE_FORMAT and TIME_FORMAT Output Formats format ParameterOutput Format %r12-hour time (hh:mm:ss (AM|PM)) %T24-hour time (hh:mm:ss) %YNumeric year, 4 digits %yNumeric year, 2 digits %mMonth with leading 0 (01, 02-12) %cMonth without leading 0 (1, 2-12) %MMonth name (January, February, and so on) %bMonth name, abbreviated (Jan, Feb, and so on) %DDay of the month with an English suffix (1st, 2nd, and so on) %dDay of the month with leading 0 (00, 01, 02-31) %eDay of the month without leading 0 (0, 1, 2-31) %WWeekday name (Sunday, Monday, and so on) %aWeekday name, abbreviated (Sun, Mon, and so on) %HHour (00, 01-23) %kHour (0, 1-23) %hHour (01, 02-12) %IHour (01, 02-12) %lHour (1, 2-12) %iMinutes (00, 01-59) %SSeconds (00, 01-59) %sSeconds (00, 01-59) %PAM or PM %UWeek number in the year,in which Sunday is the first day of the week $uWeek number in the year,in which Monday is the first day of the week %X & %VYear and week number, respectively,in which Sunday is the first day of the week %x & %vYear and week number, respectively,in which Monday is the first day of the week %jDay of year with leading 0's (001, 002-366) %wWeekday number (0=Sunday, 1=Monday, and so on) %%Literal % mysql> mysql> SELECT FROM_UNIXTIME(1000000000, '%W, %M'); +-------------------------------------+ | FROM_UNIXTIME(1000000000, '%W, %M') | +-------------------------------------+ | Saturday, September                 | +-------------------------------------+ 1 row in set (0.00 sec) mysql>