PHP Knowledge Base
PHP time format
characters
Hour
format character | Example returned values | Description |
---|---|---|
g | 1 to 12 | 12-hour format without leading zeros |
G | 0 to 23 | 24-hour format without leading zeros |
h | 01 through 12 | 12-hour format with leading zeros |
H | 00 through 23 | 24-hour format with leading zeros |
B | 000 through 999 | Swatch Internet time |
Minutes
format character | Example returned values | Description |
---|---|---|
i | 00 to 59 | Minutes with leading zeros |
Seconds
format character | Example returned values | Description |
---|---|---|
s | 00 through 59 | Seconds with leading zeros |
Microseconds
format character | Example returned values | Description |
---|---|---|
u | Example: 654321 | Added in PHP 5.2.2. Note that date() will always generate 000000 since it takes an integer parameter, whereas DateTime::format() does support microseconds if DateTime was created with microseconds. |
Milliseconds
format character | Example returned values | Description |
---|---|---|
v | Example: 654 | Added in PHP 7.0.0. Same note applies as for u. |