SSISO Community

최대균

날자계산 - 시작일,마감일 -간격계산 주간,일자,시간,초 까지

text        =  $aa[0]  

weeks      =  $aa[1]  
days        =  $aa[2]  
hours      =  $aa[3]  
minutes  =  $aa[4]  
seconds  =  $aa[5]  ";  
//  -----------------------------------------  function  dateDiff($dateTimeBegin,$dateTimeEnd)  {      $dateTimeBegin  =strtotime($dateTimeBegin);      $dateTimeEnd    =strtotime($dateTimeEnd);      if($dateTimeEnd  ===  -1  ||  $dateTimeBegin  ===  -1)  {        #  error  condition        return  false;      }      $diff  =  $dateTimeEnd  -  $dateTimeBegin;      if  ($diff  <  0)  {        #  error  condition        return  false;      }      $weeks  =  $days  =  $hours  =  $minutes  =  $seconds  =  0;  #  initialize  vars      if($diff  %  604800  >  0)  {        $rest1    =  $diff  %  604800;        $weeks    =  ($diff  -  $rest1)  /  604800;  #  seconds  a  week        if($rest1  %  86400  >  0)  {            $rest2  =  ($rest1  %  86400);            $days    =  ($rest1  -  $rest2)  /  86400;  #  seconds  a  day            if(  $rest2  %  3600  >  0  )  {                $rest3  =  ($rest2  %  3600);                $hours  =  ($rest2  -  $rest3)  /  3600;  #  seconds  an  hour                if(  $rest3  %  60  >  0  )  {                    $seconds  =  ($rest3  %  60);                    $minutes  =  ($rest3  -  $seconds)  /  60;    #  seconds  a  minute                }  else  {                    $minutes  =  $rest3  /  60;                }            }  else  {                $hours  =  $rest2  /  3600;            }        }  else  {            $days  =  $rest1/  86400;        }      }else  {        $weeks  =  $diff  /  604800;      }      $string  =  array();      if($weeks  >  1)  {        $string[]    =  "$weeks  weeks";      }  elseif  ($weeks  ==  1)  {        $string[]    =  "a  week";      }      if($days  >  1)  {        $string[]  =  "$days  days";      }  elseif($days  ==  1)  {        $string[]  =  "a  day";      }      if($hours  >  1)  {        $string[]  =  "$hours  hours";      }  elseif  ($hours  ==  1)  {        $string[]  =  "an  hour";      }      if($minutes  >  1)  {        $string[]  =  "$minutes  minutes";      }  elseif  ($minutes  ==  1)  {        $string[]  =  "a  minute";      }      if($seconds  >  1)  {        $string[]  =  "$seconds  seconds";      }  elseif($seconds  ==  1)  {        $string[]  =  "a  second";      }      #  최종적으로    함수를  모아서...---      $text    =  join(',  ',  array_slice($string,0,sizeof($string)-1))  .  ",  and  ";      $text  .=  array_pop($string);    #  put  the  last  one  on  after  the  and            return  array($text,  $weeks,  $days,  $hours,  $minutes,  $seconds);  }  
?>  

1595 view

4.0 stars