PHP獲取本月時間


獲取本月第一天到最后一天

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");
    $today = '2020-2-1';
   $day=getthemonth($today);
   echo "當月的第一天: ".$day[0]." 當月的最后一天: ".$day[1];
   echo "<br/>";

 

獲取本月第一天到今天

function getthemonth($date)
   {
   $firstday = date('Y-m-01', strtotime($date));
   $lastday = date('Y-m-d', strtotime($date));
   return array($firstday,$lastday);
   }
   //$today = date("Y-m-d");
    $today = '2020-2-6';
   $day=getthemonth($today);
   echo "當月的第一天: ".$day[0]." 當月的最后一天: ".$day[1];
   echo "<br/>";


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM