php date strtotime的用法
阿新 • • 發佈:2017-06-05
nth turn date cnblogs function spa cti blog bsp
1.上個月第一天及最後一天. echo date(‘Y-m-01‘, strtotime(‘-1 month‘)); echo strtotime(date(‘Y-m-01 0:00:00‘, strtotime(‘-1 month‘))); //月初第一天時間戳 echo "<br/>"; echo date(‘Y-m-t‘, strtotime(‘-1 month‘)); echo "<br/>"; 2.獲取當月第一天及最後一天. $BeginDate=date(‘Y-m-01‘, strtotime(date("Y-m-d"))); echo$BeginDate; echo "<br/>"; echo date(‘Y-m-d‘, strtotime("$BeginDate +1 month -1 day")); echo "<br/>"; 3.獲取當天年份、月份、日及天數. echo " 本月共有:".date("t")."天"; echo " 當前年份".date(‘Y‘); echo " 當前月份".date(‘m‘); echo " 當前幾號".date(‘d‘); echo "<br/>"; 4. 獲取當月第一天及最後一天 functiongetthemonth($date) { $firstday = date(‘Y-m-01‘, strtotime($date)); $lastday = date(‘Y-m-t‘, strtotime($date)); return array($firstday,$lastday); } $today = date("Y-m-d"); $day=getthemonth($today); echo "當月的第一天: ".$day[0]." 當月的最後一天: ".$day[1]; echo "<br/>";
php date strtotime的用法