>  기사  >  백엔드 개발  >  2000년 노벨문학상 2000년 1월 1일부터 지정된 날짜까지의 일수를 계산합니다.

2000년 노벨문학상 2000년 1월 1일부터 지정된 날짜까지의 일수를 계산합니다.

WBOY
WBOY원래의
2016-07-29 08:34:08906검색

2000년 1월 1일부터 지정한 날짜까지의 일수를 계산하는 함수입니다.


(시작과 끝도 함께 계산됩니다.) 날짜 형식은 YYYY-MM-DD
// 2000년 1월 1일부터 특정 날짜까지의 일수 계산
function cal_start2end($end_day,$start_day)
{
$start_day=ereg_replace ("-","",$start_day)
$end_day=ereg_replace("-","",$end_day)
if($end_day>=$start_day)
{ // Ending 날짜가 시작 날짜보다 큽니다
if(substr($end_day,0,4)==substr($start_day,0,4))
{
if( is_int( substr($end_day,0,4) /4) )
$leap_day=29; //윤년
else
$leap_day=28
// $leap_day=29; 연도
if(substr($end_day,4,2 )==substr($start_day,4,2))
                                                                
        그렇지 않으면
            {
//            동월이 아님
            전환(substr($end_day,4,2))
                {              케이스 '01':
                       $endday_from_newyear=substr ($end_day,6,2) 1;
                       휴식;
               케이스 '02':
                      $endday_from_newyear=substr($end_day,6,2) 31;
                       휴식;
               케이스 "03":
                      $endday_from_newyear=substr($end_day,6,2) $leap_day 31;
                       휴식;
               케이스 "04":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*2;
                       휴식;
               케이스 "05":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*2 30;
                       휴식;
               케이스 "06":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*3 30;
                       휴식;
               케이스 "07":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*2 30*2;
                       휴식;
               케이스 "08":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*3 30*2;
                       휴식;
               케이스 "09":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*2;
                       휴식;
               대소문자 "10":
                        $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*3;
                       휴식;
               대소문자 "11":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*4;
                       휴식;
               대소문자 "12":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*5;
                       휴식;
               }
            $endday_from_startday=$endday_from_newyear;
            }
반품($endday_from_startday);
        }
    else
        {
//        동일하지 않습니다!
$differ_year=substr($end_day,0,4)-substr($start_day,0,4);
$how_int_4_floor=floor($differ_year/4) 1; // 向下取整
$how_int_4_ceil=ceil($differ_year/4) 1; // 向上取整
if($how_int_4_floor==$how_int_4_ceil)
    $how_leap_year=$how_int_4_floor-1;
그 외
    $how_leap_year=$how_int_4_floor;
$how_noleap_year=$differ_year-$how_leap_year;
$differ_year2day=$how_noleap_year*365 $how_leap_year*366;
if( is_int(substr($end_day,0,4)/4) )
    $leap_day=29;    //윤년
else
    $leap_day=28;
        if(substr($end_day,4,2)==substr($start_day,4,2))
            {
//           동월  
           $endday_from_startday=$differ_year2day substr ($end_day ,4,2);
            }
        그렇지 않으면
            {
//            동월이 아님
            전환(substr($end_day,4,2))
                {              케이스 '01':
                       $endday_from_newyear=substr ($end_day,6,2) 1;
                       휴식;
               케이스 "02":
                      $endday_from_newyear=substr($end_day,6,2) 1 31;
                       휴식;
               케이스 "03":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31;
                       휴식;
               케이스 "04":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*2;
                       휴식;
               케이스 "05":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*2 30;
                       휴식;
               케이스 "06":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*3 30;
                       휴식;
               케이스 "07":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*2 30*2;
                       휴식;
               케이스 "08":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*3 30*2;
                       휴식;
               케이스 "09":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*2;
                       휴식;
               대소문자 "10":
                        $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*3;
                       휴식;
               대소문자 "11":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*4;
                       휴식;
               대소문자 "12":
                      $endday_from_newyear=substr($end_day,6,2) 1 $leap_day 31*5 30*5;
                       휴식;
               } //전환 종료
    $endday_from_startday=$endday_from_newyear $differ_year2day;
    }    //같은 달이 아닌  말  
반품($endday_from_startday);
        } //연말 종료
}        //끝  $end_day>=$start_day
} //기능 종료
$start_day="2000-01-01";
$end_day="2011-01-01";
echo "您输入的是:".$end_day."
n";
$endday_from_startday=cal_start2end($end_day,$start_day);
echo "该日距离$start_day 共 ".$endday_from_startday." 天";
?>




时间太少了,那位大虾可以修改为计算任日期の间的间隔最好!!! 

以上就介绍了2000年诺贝尔文school奖 计算2000年01月01日起到指定日的天数,包括了2000年诺贝尔文school奖方亹,内容,希望对PHP教정말 많은 것들이 있습니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.