I am writing a value calculator where there are special prices for the weekend to do this, I must know that between 2 dates How many weekend are there
Note that by the end of a week I mean that they want to be on Thursday, Saturday and Sunday are not 2 days, but a weekend rate, but a weekend with a weekend In. So from Thursday -> Tuesday, this will be the count of 1 weekend.
For Saturday -> Saturday will be counted for 2 weekends, because the first Saturday is not the same weekend as the following Saturday. It will be true from Sunday to Sunday, it is counting weekends whether or not they are full weekends or partial weekends. As long as some or any part of the weekend falls within that date range, it is counted by the end of 1 week. The best analogy I can think is that at the end of the week on the same day which lasts 48 hours, not in the last 24.
So, how will I decide how many 'whole or partial weekends' are in between 2 php in the 2 days?
We have to start with determining the number of days between dates. Something like this
$ n = floor ((Timestamp_and - timestamp_start) / 86400); If you say that Saturday-> Saturday = 2, until our starting day is not Saturday and the quantity of day 7 is a product, weekend number $ n / 7, otherwise, $ n / 7 + 1 then We can start with. $ n_weekends = roof ($ n / 7);
and then
if (date ("n", timestamp_start) == 6 and $ n% 7 == 0) {$ n_weekends ++; }
Comments
Post a Comment