您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP时间日期处理整理

2024/7/7 5:20:26发布26次查看
//返回一个时间段内所有月份 传时间戳function monthlist($start,$end){ if(!is_numeric($start)||!is_numeric($end)||($end $start=date('y-m',$start); $end=date('y-m',$end); //转为时间戳 $start=strtotime($start.'-01'); $end=strtotime($end.'-01'); $i=0; $d=array(); while($start //这里累加每个月的的总秒数 计算公式:上一月1号的时间戳秒数减去当前月的时间戳秒数 $d[$i]=trim(date('y-m',$start),' '); $start+=strtotime('+1 month',$start)-$start; $i++; } return $d; }//返回一个时间段内周的开始和结束日期 传date类型function monthlist($start,$end){ if(!is_numeric($start)||!is_numeric($end)||($end $start=date('y-m',$start); $end=date('y-m',$end); //转为时间戳 $start=strtotime($start.'-01'); $end=strtotime($end.'-01'); $i=0; $d=array(); while($start //这里累加每个月的的总秒数 计算公式:上一月1号的时间戳秒数减去当前月的时间戳秒数 $d[$i]=trim(date('y-m',$start),' '); $start+=strtotime('+1 month',$start)-$start; $i++; } return $d; }//返回一个月份的第一天和最后一天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);
复制代码
php
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product