Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to set 1 year date without saturday in while loop php

// returned $date Y/m/d
function work_days_from_date($days, $forward, $date=NULL) 
{
    if(!$date)
    {
        $date = date('Y-m-d'); // if no date given, use todays date
    }

    while ($days != 0) 
    {
        $forward == 1 ? $day = strtotime($date.' +1 day') : $day = strtotime($date.' -1 day');
        $date = date('Y-m-d',$day);
        if( date('N', strtotime($date)) <= 5) // if it's a weekday
        {
          $days--;
        }
    }
    return $date;
}
Comment

PREVIOUS NEXT
Code Example
Php :: Laravel Extract Values From Collection Using Pluck() with Relationship 
Php :: make model factory and controller laravel 
Php :: wp add_action 
Php :: image not save laravel 
Php :: Redirect to HTTPS & remove www 
Php :: laravel get url parameters in controller 
Php :: twig render to string 
Php :: find the next 7 date data in laravel eloquent 
Php :: codeigniter check view file exists 
Php :: parse php 
Php :: Print array to a file 
Php :: what is the use of migration file in laravel 
Php :: post rest drupal 
Php :: laravel Pushing To Array Session Values 
Php :: delete record without a page refresh with ajax in php 
Php :: jquery get data from php 
Php :: Publish Spatie Laravel Permission 
Php :: creating jobs laravel 
Php :: php in html need .htaccess 
Php :: php vs python speed 
Php :: php array 
Php :: main.php 
Php :: how to run a php file using 
Php :: crypt password php 
Php :: laravel collection 
Php :: extract in php useful 
Php :: Undefined index: name laravel 
Php :: route group laravel 8 
Php :: findOneBy 
Php :: php how to concatenate strings 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =