PHP-从时差中排除所有非营业时间/天 [英] PHP - Exclude all non-business hours / days from time difference
本文介绍了PHP-从时差中排除所有非营业时间/天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格,显示自从提出工作以来的时间.
I have a table which shows the time since a job was raised.
// These are unix epoch times...
$raised = 1360947684;
$now = 1361192598;
$difference = 244914;
$difference
需要排除工作时间以外的任何时间(例如9-5和周末).
$difference
needs to exclude any time outside of business hours (ex, 9-5 and weekends).
我该如何解决?
推荐答案
您要做的是3个数字.
The thing you have to do are 3 in numbers.
- 您以开始日期为准,并计算这一天(如果是工作日)的休息时间
- 您确定结束日期并计算当天的时间,并且
- 您将介于两天之间的时间乘以营业时间(正好是营业日)
并且有了那,您就完成了.
And with that you are done.
找到一个附属的类,它可以完成这些任务.请注意,没有错误处理,时区设置,夏令时……
Find a little class attached, which does those things. Be aware that there is no error handling, time zone settings, daylight saving time, ...
输入:
- 开始日期
- 结束日期
输出:
- 以秒为单位的差异时间
可调常数:
- 营业时间
- 不是工作日的日子
这篇关于PHP-从时差中排除所有非营业时间/天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文