在PHP中,可以使用 date 函数来获取当前时间。
$currentTime = date("Y-m-d H:i:s");
这将返回当前时间的字符串表示,格式为 年-月-日 时:分:秒
。
其中,Y
表示年份,m
表示月份,d
表示日期,H
表示小时(24小时制),i
表示分钟,s
表示秒钟。
如果你需要获取当前时间的时间戳(Unix时间戳),可以使用 time 函数:
$timestamp = time();
这将返回当前时间的时间戳,即从1970年1月1日00:00:00 UTC到当前时间的秒数。