| MySQL | PHP | Description |
|---|---|---|
| Day | ||
| %d | d | Day of the month, numeric (00..31) |
| %a | D | A textual representation of a day, three letters (Mon - Sun) |
| %e | j | Day of the month without leading zeros (0..31) |
| %D | jS | Day of the month with English suffix (0th, 1st, 2nd, 3rd, …) |
| %W | l | A full textual representation of the day of the week (Sunday - Saturday) |
| %w | w | Day of the week (0=Sunday..6=Saturday) |
| Month | ||
| %M | F | Month name (January..December) |
| %b | M | Abbreviated month name (Jan..Dec) |
| %c | n | Month, numeric (0..12) |
| %m | m | Month, numeric (00..12) |
| Year | ||
| %Y | Y | Year, numeric, four digits |
| %y | y | Year, numeric (two digits) |
| Time | ||
| %H | H | Hour (00..23) |
| %h | h | Hour (01..12) |
| %k | G | Hour (0..23) |
| %l | g | Hour (1..12) |
| %i | i | Minutes, numeric (00..59) |
| %s | s | Seconds (00..59) |
| %f | u | Microseconds (000000..999999) |
| %p | A | AM or PM |
| %r | g:i:s A | Time, 12-hour (hh:mm:ss followed by AM or PM) |
| %T | H:i:s | Time, 24-hour (hh:mm:ss) |
| Misc | ||
| %M %e, %Y | F j, Y | Month Day, Year |
| %% | % | A literal % character |
| Type | Bytes | Signed | Unsigned |
|---|---|---|---|
| TINYINT | 1 | -128 to 127 | 0 to 255 |
| SMALLINT | 2 | -32768 to 32767 | 0 to 65535 |
| MEDIUMINT | 3 | -8388608 to 8388607 | 0 to 16777215 |
| INT, INTEGER | 4 | -2147483648 to 2147483647 | 0 to 4294967295 |
| BIGINT | 8 | -9223372036854775808 to 9223372036854775807 | 0 to 18446744073709551615 |
| FLOAT | 4 | ||
| FLOAT(p) | varies | ||
| DOUBLE [PRECISION], REAL | 8 | ||
| DECIMAL(M,D), NUMERIC(M,D) | varies | ||
| BIT(M) | ~ M+7 |
Best for Zip+4: INT UNSIGNED
Best for xxx-xxx-xxxx phone: BIGINT UNSIGNED
From MySQL 5.4 Reference Manual: Numeric Types
| Type | Bytes | Notes |
|---|---|---|
| CHAR(M), BINARY(M) | 0 - 255 | |
| VARCHAR(M), VARBINARY(M) | M + 1 <= 255; M + 2 > 255 | |
| TINYBLOB, TINYTEXT | 2 - 255 | |
| BLOB, TEXT | 3 - 65535 | |
| MEDIUMBLOB, MEDIUMTEXT | 4 - 16777215 | |
| LONGBLOB, LONGTEXT | 5 - 4294967295 | |
| ENUM('value1','value2',...) | 1 - 2 | 65,535 values maximum |
| SET('value1','value2',...) | 1, 2, 4 or 8 | 64 values maximum |
From MySQL 5.4 Reference Manual: Data Type Storage Requirements