Posted on 2003-03-19
I have a Problem.
I am working on something like Message Forums.
Every Post Is Displayed only for 4 days Publically after Its Posted.
I store the date_entered values as time() in database (ie $now = time() and then store $now in date_entered field).
WHile Displaying the posts, I do Grouping
ie 1st Day, 2nd Day, 3rd Day and Final Day.
So those Posts which are Posted today come Under 1st Day Heading.
Problem is I dont have to count weekends(saturday/sundays) and some holidays that are defined by admin. So if I post on Monday and Monday is a holiday, Monday and Tuesday both will be the First Day.
If I post on Saturday, then sat/sun/mon will be First day (if monday is not a holiday). If monday is a holiday, then sat/sun/mon/tue all will be first day.
I hope I made myself clear.
How do I achieve this. I am all lost.
I have decided the best way to do is keep 4 fields in database (firstday, secondday, thirdday, fourthday) and while Inserting, do the calculations and insert proper values. This way while displaying I can just select and Display, no hard calculations.
Any Code Samples for this?