中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

PHP時(shí)間日期處理整理

2018-07-20    來源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用
 //返回一個(gè)時(shí)間段內(nèi)所有月份  傳時(shí)間戳

function monthList($start,$end){
     if(!is_numeric($start)||!is_numeric($end)||($end<=$start)) return '';
     $start=date('Y-m',$start);
     $end=date('Y-m',$end);
     //轉(zhuǎn)為時(shí)間戳
     $start=strtotime($start.'-01');
     $end=strtotime($end.'-01');
     $i=0;
     $d=array();
     while($start<=$end){
         //這里累加每個(gè)月的的總秒數(shù) 計(jì)算公式:上一月1號(hào)的時(shí)間戳秒數(shù)減去當(dāng)前月的時(shí)間戳秒數(shù)
         $d[$i]=trim(date('Y-m',$start),' ');
         $start+=strtotime('+1 month',$start)-$start;
         $i++;
     }
     return $d;

 }

//返回一個(gè)時(shí)間段內(nèi)周的開始和結(jié)束日期    傳date類型

function monthList($start,$end){
        if(!is_numeric($start)||!is_numeric($end)||($end<=$start)) return '';
        $start=date('Y-m',$start);
        $end=date('Y-m',$end);
        //轉(zhuǎn)為時(shí)間戳
        $start=strtotime($start.'-01');
        $end=strtotime($end.'-01');
        $i=0;
        $d=array();
        while($start<=$end){
            //這里累加每個(gè)月的的總秒數(shù) 計(jì)算公式:上一月1號(hào)的時(shí)間戳秒數(shù)減去當(dāng)前月的時(shí)間戳秒數(shù)
            $d[$i]=trim(date('Y-m',$start),' ');
            $start+=strtotime('+1 month',$start)-$start;
            $i++;
        }
        return $d;
    }

//返回一個(gè)月份的第一天和最后一天

function getthemonth($date)  
{  
$firstday = date('Y-m-01', strtotime($date));  
$lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));  
return array($firstday,$lastday);  
}  
$today = date("Y-m-d");  
$day=getthemonth($today);  

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:用開源項(xiàng)目PHPMailer實(shí)現(xiàn)郵件發(fā)送

下一篇:cocos2dx代碼調(diào)用本地瀏覽器步驟詳解