首頁 > 後端開發 > php教程 > 2000年諾貝爾文學獎 計算2000年01月01日為指定日的天數

2000年諾貝爾文學獎 計算2000年01月01日為指定日的天數

WBOY
發布: 2016-07-29 08:34:08
原創
924 人瀏覽過

這是一個計算2000年01月01日起到指定日的天數的函數


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


//    計算從2000年01月01日開始到某日的天數
function cal_start2end($end_day,$start_day)
{
$start_day=ereg_ ","",$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,044) )
    $leap_day=29;    //leap year
else
    $leap_day=     if(substr($end_day,4,2)== substr($start_day,4,2))
            {
//           rom_startday=$end_day-$start_day+1;
            }
        其他
            {
//       str($end_day,4,2))
                {
                       $endday_from_newyear= substr ($end_day,6,2)+1;
                        休息;
                案例"02":
                        $endday_from_newyear=substr($end_day,6,2)+31;
                        休息;
                案例中"03":              31;
                        與的休息;
                      $endday_from_newyear=substr($end_day ,6,2)+1+$leap_day+31*2;
                       🎜>                        $endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31 *2+30;
                        的休息;
         休息;
                       $endday_from_newyear=substr($end_day,6,2)+1+$      休息;
                                 +$leap_day+31*2+30*2;
                         
                       $endday_from_newyear=substr($end_day,6,             休息;
                  $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":
                      地6,2)+1+$leap_day+31*5+30*4;
                       ":
                       $endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,62)+1+$ leap_day+31*5+30*5;
                                  $endday_from_startday=$endday_from_newyear;
            }         {
//         不同年!
$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+ ($end _day, 4, 2);
            }
        其他
            {
//       str($end_day,4,2))
                {
                       $endday_from_newyear= substr ($end_day,6,2)+1;
                        休息;
                案例"02":
                        $endday_from_newyear=substr($end_day,6,2)+1+31;
                        休息;
                                 +$leap_day+31;
                                                  $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;
                                                 $endday_from_newyear=substr($end_day,6,2)+1+$leap_day+31*3+30
                        休息;
                       $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+$endday_from_newyear=substr($end_day,6,2)+1+$leapday+31               休息;
                   $ 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":
                      地6,2)+1+$leap_day+31*5+30*4;
                       ":
                       $endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,6,2)+1+$endday_from_newyear=substr($end_day,62)+1+$ //leap_day+31*5+30*5;
                            $endday_from_startday=$endday_from_newyear+$differ_year2day;
    }    //不同月結束  
return ($endday_from_startday );
        } //年末
}        //結束$end_day>=$start_day
} //沒有"2011-01-01";
echo "您輸入的是:".$end_day."
n";
$endday_from_startday=cal_start2end($end_day,$start_day);
echo "該日距離$start_day 共".$endday_from_startday." 天";
? >




時間太少了,那個大蝦可以修改為計算任兩個日期之間的間隔最好! ! ! ! 
以上就介紹了2000年諾貝爾文學獎計算2000年01月01日指定希望日的天數,包括2000年諾貝爾文學獎方面的內容,對PHP教程有興趣的朋友有所幫助。


相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板