sujit prasad sujit prasad - 1 month ago 6x
PHP Question

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.


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.

See DateTime::format('w') and be sure to click through to the date() format description see what else can be used!