Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to exclude weekend and holidays

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to exclude weekend and holidays

Postby scorpio76 » Sun Aug 11, 2013 4:44 am

Currently i have developed a file processing system. One of the system function is to count number of days
Which should not exceed 30 days to process an application. If exceed 30 days, flash message appears to inform user processing date exceded 30 days. Any example how to write function for this?
I m using codeigniter php.
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Jul 30, 2013 6:38 am

Re: How to exclude weekend and holidays

Postby johnj » Mon Aug 12, 2013 1:18 am

something like this:
Code: Select all

function has_exceeded_30_days($app_date)
// do necessary validations
// todays date should be in the same format as that of application date

$diff_in_secs = strtotime($todays_date) - strtotime($app_date);
$diff_in_days = floor($diff_in_secs/3600/24);
if ($diff_in_days > 30)
    return TRUE;
return FALSE;

Usually this function is placed in the Library of CI. A controller call is then placed to this function and if the function returns TRUE then appropriate view is loaded to flash the message.
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.