像 12:33:00 一样获取 PHP 中的当前时间
Get current time in PHP like 12:33:00
我正在尝试获取 PHP 中的当前时间,以便我可以将其存储在数据库中。
当我做的时候
$currentTime = time();
或
$currentTime = time('hh:ii:ss');
我得到的结果类似于
1428492931
但我希望时间格式正确,例如
12:33:00
它是日期而非时间函数
date('h:i:s');
time
— Return 当前 Unix 时间戳
说明
int time ( void ) Returns the current time measured in the number of
seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
我正在尝试获取 PHP 中的当前时间,以便我可以将其存储在数据库中。
当我做的时候
$currentTime = time();
或
$currentTime = time('hh:ii:ss');
我得到的结果类似于
1428492931
但我希望时间格式正确,例如
12:33:00
它是日期而非时间函数
date('h:i:s');
time
— Return 当前 Unix 时间戳
说明
int time ( void ) Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).