<br>
(算頭也算尾)日期格式為:YYYY-MM-DD
<br>

<?php
// 計(jì)算從2000年01月01日開始到某日的天數(shù)

function cal_start2end($end_day,$start_day)
{


$ " /> 又黄又免费,精品国产一区二区二三区在线观看,欧美×x

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

計(jì)算2000年01月01日起到指定日的天數(shù)

這是一個(gè)計(jì)算2000年01月01日起到指定日的天數(shù)的函數(shù)
<br>
(算頭也算尾)日期格式為:YYYY-MM-DD
<br>

<?php
//    計(jì)算從2000年01月01日開始到某日的天數(shù)

function cal_start2end($end_day,$start_day)
{


$start_day=ereg_replace("-","",$start_day);
$end_day=ereg_replace("-","",$end_day);



if($end_day>=$start_day)
{    //    截止日期大于開始日期
    if(substr($end_day,0,4)==substr($start_day,0,4))
        {

if( is_int(substr($end_day,0,4)/4) )
    $leap_day=29;    //leap year
else
    $leap_day=28;


//            //同一年

        if(substr($end_day,4,2)==substr($start_day,4,2))
            {
//            the same month  
            $endday_from_startday=$end_day-$start_day+1;

            }
        else
            {
//             not same month


            switch (substr($end_day,4,2))
                {
                case "01":
                        $endday_from_newyear=substr($end_day,6,2)+1;
                        break;
                case "02":
                        $endday_from_newyear=substr($end_day,6,2)+31;
                        break;
                case "03":
                        $endday_from_newyear=substr($end_day,6,2)+$leap_day+31;
                        break;
                case "04":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*2;
                        break;
                case "05":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*2+30;
                        break;
                case "06":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*3+30;
                        break;
                case "07":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*2+30*2;
                        break;
                case "08":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*3+30*2;
                        break;
                case "09":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*2;
                        break;
                case "10":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*3;
                        break;
                case "11":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*4;
                        break;
                case "12":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*5;
                        break;
                }
            $endday_from_startday=$endday_from_newyear;
            }

return ($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;
else
    $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;    //leap year
else
    $leap_day=28;



        if(substr($end_day,4,2)==substr($start_day,4,2))
            {
//            the same month  
            $endday_from_startday=$differ_year2day+ substr($end_day,4,2);

            }
        else
            {
//             not same month


            switch (substr($end_day,4,2))
                {
                case "01":
                        $endday_from_newyear=substr($end_day,6,2)+1;
                        break;
                case "02":
                        $endday_from_newyear=substr($end_day,6,2)+1+31;
                        break;
                case "03":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31;
                        break;
                case "04":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*2;
                        break;
                case "05":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*2+30;
                        break;
                case "06":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*3+30;
                        break;
                case "07":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*2+30*2;
                        break;
                case "08":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*3+30*2;
                        break;
                case "09":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*2;
                        break;
                case "10":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*3;
                        break;
                case "11":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*4;
                        break;
                case "12":
                        $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*5+30*5;
                        break;
                } //End of switch


    $endday_from_startday=$endday_from_newyear+$differ_year2day;
    }    //End of  not same month  



return ($endday_from_startday);


        } //End of year
}        //End of  $end_day>=$start_day



} //End of function


$start_day="2000-01-01";

$end_day="2011-01-01";

echo "您輸入的是:".$end_day."<br>/n";
$endday_from_startday=cal_start2end($end_day,$start_day);

echo "該日距離$start_day 共 ".$endday_from_startday." 天";

?>
<br><br><br><br>時(shí)間太少了,那位大蝦可以修改為計(jì)算任意兩日期之間的間隔最好!!!!! 

php技術(shù)計(jì)算2000年01月01日起到指定日的天數(shù),轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 精品久久九九 | 国产美女无遮挡免费视频 | 9299yy看片淫黄大片在线 | 精品一精品国产一级毛片 | 日本乱中文字幕系列在线观看 | 老太婆性杂交欧美肥老太 | 3www黄| 婷婷婷色 | 9久9久女女热精品视频免费观看 | 热久久久久久 | 亚洲一区二区三区高清视频 | 天堂在线www天堂中文在线 | 爱爱一区 | 国产视频一二区 | 国产精品久久现线拍久青草 | 国产美女激情视频无打码 | 亚洲精品视频二区 | 久久大香香蕉国产免费网站 | 亚洲婷婷综合网 | 亚洲情综合五月天 | 99爱在线视频这里只有精品 | 久久精品精品 | 91精品在线免费观看 | 亚洲免费二区 | 欧美高清另类videosbestsex | 韩国美女一级片 | 美女色哟哟 | 亚洲一级特黄 | 中文字幕区 | 久久久精品中文字幕 | 免费视频一区二区三区四区 | 91大神在线精品网址 | 加勒比精品久久一区二区三区 | 精品久久国产 | 九九色视频 | www.色午夜.com| 五月婷婷丁香综合 | 国产精品第一页在线 | 成人春色在线观看免费网站 | 点击进入不卡毛片免费观看 | 国产欧美曰韩一区二区三区 |