我正在使用laravel开发API,我被困在一个点上,计算两个时间戳之间的时间差,.my数据库在另一个区域存在,我的机器运行在UTC定时上,所以我无法找到两个时间戳之间的确切时间差,是否有任何方法在查询级别上检查时间戳,我已经尝试过了,但是它没有按预期工作。
$childdata = $childConnection->query("select useractivitytime,idfrom userdetails where status = 0");
$current_date_time = Carbon::now()->format('Y-m-d h:i:s'); // this gives me the application running time.
$difference_in_seconds = strtotime($current_date_time) - strtotime($value['js_useractivity']); //result in seconds.发布于 2022-11-04 08:05:14
尝试使用TIMEDIFF
select
TIME_TO_SEC(TIMEDIFF(NOW(), useractivitytime)) AS difference_in_seconds,
id
from
userdetails
where
status = 0https://stackoverflow.com/questions/74312657
复制相似问题