今天我绞尽脑汁,做了一些搜索,但没有找到任何好的答案。看看我的例子。
$time_now = date("H:i:s"); // The current time. (let's say the clock is 14:25:33)
$time_visited = "14:23:33"; // the time page was visited. (set by cookie)
假设我想得到$time_visited和$time_now之间的时间(秒)(应该是120秒)获取/计算这些值之间秒数的最简单方法是什么?
time()返回当前时间戳,strtotime()将给定字符串解析为时间戳
time() - strtotime("14:23:33")