如何使用计划工作黑白两个时间戳计算时差? [英] How to calculate time difference with schedule working b/w two time stamps?
本文介绍了如何使用计划工作黑白两个时间戳计算时差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这种情况下,我有一个像这样的任务start_time
和end_time
的表,在启动方法中,我注意到start_time
和在暂停/审阅/完成时我注意到end_time
这是我的表
Here is the scenario that i have a table of task start_time
and end_time
like this, On start method i note start_time
and On pause/in review/done i note the end_time
here is my table
ID | task_id | start_time | end_time
-----------------------------------------------------------------
1 1 2017-03-02 06:27:28 2017-03-12 10:43:37
2 5 2017-03-02 07:16:05 NULL//in progress no end time
例如,我要计算一周中从 6 到 10 的上班时间和工作日 工作日轮班时间中的确切时间.我已经进行了很多搜索以找到答案,请使用正确的计算方法为我提供帮助.
for example there are shifting hours from 6 to 10 and working days in week i want to calculate exact time during shifting hours in working days. I have searched a lot to find the answer please help me with a proper calculation method.
注意:在end_time
是 NULL 的地方,我用date()
表示当前日期
Note: where end_time
is NULL there i use date()
means current date
推荐答案
<?php
$datetime1 = new DateTime('2017-03-02 06:27:28');
if($datetime1->format("D")!="Sun" && $datetime1->format("D")!="Sat")
{
$datetime2 = new DateTime('2017-03-12 10:43:37');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%H:%I:%s');
}
这篇关于如何使用计划工作黑白两个时间戳计算时差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文