简体   繁体   English

Php根据周末检查假期列表的确切日期和时间

[英]Php check exact date and time with holiday listing based on weekends

Scenario :- I have a list of holidays but the date themselves don't know weather they are week days or week ends.场景:- 我有一个假期列表,但日期本身不知道他们是工作日还是周末的天气。 Based on the calculation of date time with holiday listing and weekend/weekdays.基于假日列表和周末/工作日的日期时间计算。

I have to make a list of calculations based on date and time and holidays added by the user dynamically, and each week day does not have any fixed working hours so removing a fixed hour from a date is not possible.我必须根据用户动态添加的日期和时间以及假期制作一个计算列表,并且每个工作日没有任何固定的工作时间,因此无法从日期中删除固定的时间。

Also the dates are suppose to be calculated based on the year.此外,假设日期是根据年份计算的。 So if a date in a year is weekday the date will be included and if another year has the same date as weekend the date will be excluded.因此,如果一年中的某个日期是工作日,则该日期将被包括在内,如果另一年的日期与周末相同,则该日期将被排除。

Date calculation based on the year and week ends/week days will be smarter.基于年和周结束/工作日的日期计算会更智能。

PHP will be preferred. PHP 将是首选。

Based on the discussion in the comments, the question is about how to find out if a given date on a weekend.根据评论中的讨论,问题是如何确定给定日期是否在周末。

The 'w' formatting flag can be used to determine the day of the week of a given date, which can be checked against 0 or 6 which indicate Sunday or Saturday. 'w' 格式标志可用于确定给定日期的星期几,可以根据表示星期日或星期六的 0 或 6 进行检查。

See DateTime::format('w') and be sure to click through to the date() format description see what else can be used!请参阅DateTime::format('w')并确保点击进入date()格式说明,看看还有什么可以使用的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM