我使用 PHP 已经有一段时间了——但是当我需要使用它date()
来格式化时间时,我永远无法正确记住小时的语法。有什么技巧可以记住使用 g/G/h/H 的韵律和原因吗?
来自 PHP 手册date()
:
g | 12-hour format of an hour without leading zeros | 1 through 12
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
H | 24-hour format of an hour with leading zeros | 00 through 23
并以图像格式:
php-time.png http://img593.imageshack.us/img593/5338/phptime.png