Add X days to current date and calculate excluding saturdays and sundays - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Add X days to current date and calculate excluding saturdays and sundays (/showthread.php?tid=55271) |
Add X days to current date and calculate excluding saturdays and sundays - El Forum - 10-17-2012 [eluser]ninjayan[/eluser] Hello everyone! I am currently developing a document tracking application which will calculate the duration of document. So the number of days to be added from the current date (document creation) is set from the database (dynamic). I have this code but this will not make it dynamic since the number of days to be added is hard coded. Code: $add = 5; So the code above is just to illustrate what I want to achieve. Add X days to current date and calculate excluding saturdays and sundays - El Forum - 10-17-2012 [eluser]ninjayan[/eluser] If the admin updates the number of days from the database for example from the code given. 5 will becomes ten. But the problem is the fixed +7 +14 5 10. That makes it not dynamic. Add X days to current date and calculate excluding saturdays and sundays - El Forum - 10-17-2012 [eluser]benton.snyder[/eluser] Code: $add = $database->result(); // fetch the number of days stored in the database Add X days to current date and calculate excluding saturdays and sundays - El Forum - 10-17-2012 [eluser]ninjayan[/eluser] will this exclude saturdays and sundays? thanks for your input. appreciated. beginner here Add X days to current date and calculate excluding saturdays and sundays - El Forum - 10-17-2012 [eluser]benton.snyder[/eluser] That's considerably more complicated. Something like the following should do the trick though. Code: $today = new DateTime(); Add X days to current date and calculate excluding saturdays and sundays - El Forum - 10-18-2012 [eluser]ninjayan[/eluser] Thank you. I appreciate your effort. I also found this code but not so sure thou. Code: $startDate = date("M d, Y");// current date Your code also answered my problem. thanks again. |