Php时间和手动设定时间值.伯爵

Bul*_*fen 0 php time count

今天扭曲了我的大脑并做了一些搜索,但没有找到任何好的答案.看看我的例子吧.

$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)
Run Code Online (Sandbox Code Playgroud)

所以,假设我想在$ time_visited和$ time_now之间获得时间(应该是120秒)什么是在这些值之间获得/计算第二的最简单方法?

Ser*_*min 5

time()返回当前时间戳,strtotime()将给定的字符串解析为时间戳

time() - strtotime("14:23:33")
Run Code Online (Sandbox Code Playgroud)