我正在尝试计算从 MySQL 数据库检索到的时间戳与当前时间之间的差异。
感谢您的帮助。
最佳答案
如@RemoteSojourner 所述,我以 UNIX 时间戳格式获取当前时间(以秒为单位返回时间),我从数据库获取时间戳(使用 ORM)并将其转换为 UNIX 时间戳,然后减去两个时间戳。
$current_time = strtotime("now");
$last_access_time = strtotime($this->last_access);
$inactivity_duration = $current_time - $last_access_time;
关于php - 如何计算 MySQL 时间戳与 PHP 中当前时间之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5676299/