hi guys,
i am having following problem. i need to claculate starting from a given date the next month's first non holiday day. means e.g. i have the date 2007-11-01 --> the value i want to get would be 2007-12-03 - would be a monday, 2007-12-01 would be wrong.
does anyone have an idea how to realize that?
cheers
juline
calculate first non-holiday in month
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Well... If you're going to calculate it using holidays AND weekends, then you could just... store the holidays you consider valid in a database and check if that entry exists in the database before using it. As for weekends... PHP's date() function will give you the day of the week.
Just kind of increment the day, check the database, and check the day of the week. If it fails the checks, go to the next day.
Just kind of increment the day, check the database, and check the day of the week. If it fails the checks, go to the next day.
first of all thanx for helping guys,
i found following solution by googling on other forums:
first i calculate the holidays as following:
e.g. Whitsunday -->
or a static one like All Saints' Day -->
etc..
then i check the date if it is a weekend day. if sunday i add 1 day, if saturday i add 2 days.
After this i want to check if the date is one of the holidays i allready have calculated on top --- and here my problem starts:
i am checking like this , do something. I do not get any results for this if statement.
does anyone know why ???
cheers
juline
i found following solution by googling on other forums:
first i calculate the holidays as following:
e.g. Whitsunday -->
Code: Select all
$Whitsunday = date('d.m.Y', mktime(0,0,0, date ('m', easter_date($row[0])), date('d', easter_date($row[0]))+49, date('Y', easter_date($row[0]))));Code: Select all
$allsaintsday = date("d.m.Y", mktime(0,0,0,11,1, $row[0]));then i check the date if it is a weekend day. if sunday i add 1 day, if saturday i add 2 days.
After this i want to check if the date is one of the holidays i allready have calculated on top --- and here my problem starts:
i am checking like this
Code: Select all
if ($date == '$allsaintsday')does anyone know why ???
cheers
juline
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm