PHP DateTime formatting cribsheet
Describes the placeholders you can use when formatting dates in PHP or with Carbon
Usage with php datetime object or Carbon
Hour
Character | Description | Example |
H | 24-hour format of an hour with leading zeros | 00 through 23 |
G | 24-hour format of an hour without leading zeros | 0 through 23 |
h | 12-hour format of an hour with leading zeros | 01 through 12 |
g | 12-hour format of an hour without leading zeros | 1 through 12 |
a | Lowercase Ante meridiem and Post meridiem |
|
A | Uppercase Ante meridiem and Post meridiem |
|
Minutes and Seconds
Character | Description | Example |
i | Minutes with leading zeros | 00 through 59 |
s | Seconds with leading zeros | 00 through 59 |
u | Microseconds | eg 123456 |
v | Milliseconds | eg 654 |
Last updated