php - UNIX时间,响应总是一分钟(更快/更少)PHP MySQL
问题描述
我们有一个考勤门户,其中员工应用程序需要显示倒计时到他们的班次开始(例如:员工班次是 9-5,当他们在 8:50 打开他们的应用程序时,服务器将给出响应10 分钟,应用程序将开始倒计时 {9:59, 9:58....etc})
我们将所有时间存储在 UTC 中,并使用 PHP 函数转换为本地时间。
这一切都很好,直到上周我们开始注意到响应总是延迟一分钟(因此对于上面的示例,将显示剩余 9:00 分钟等)。无论轮班的时间或轮班开始时间的差异。
以下是服务器端逻辑:
$fields['total_elapsed_time'] = $current_time - strtotime($first_check_in_timestamp);
$fields['current_time'] = $current_time;
以下是应用程序逻辑:
```if currentTime < startTime {
self.isUserHaveShiftIn2Hours = true
let endDate = Date(timeIntervalSince1970: TimeInterval(startTime))
self.totalWorkingSeconds = Double(self.getNumberOfSeconds(startDate: startDate, endDate: endDate))
self.startTheCountDownForShift()
}```
`let startTime = response.result.value!.shift_start_time`
`let startDate = Date(timeIntervalSince1970: TimeInterval(currentTime))`
`let currentTime = response.result.value!.current_time`
谢谢!~
解决方案
推荐阅读
- sql - SQL:将一个表中的多个值与另一个表中的单个值进行比较
- javascript - 如何使这个 switch case 语句不那么冗长?
- python-3.x - 在终端控制台中,如何使用 python 结束/关闭循环?(我想运行循环,请不要错误结束循环)
- dart - Flutter-如何在任何文件夹中为imagePicker设置图像路径?
- python - 查找/索引使用正则表达式找到的多条语句
- python - EOFError:在 Python 中读取 raw_input 上的一行时出现 EOF
- powershell - Powershell:提取部分值并以新格式输出
- parameters - 如何使用 Dapper 库发送 DTO 中未包含的参数
- r - 根据R中列表的名称重命名数据框的列
- ios - 快速使用多部分格式数据发送带有一些参数的图像