Home  >  Article  >  Backend Development  >  PHP获取一段时间内日期列表函数

PHP获取一段时间内日期列表函数

WBOY
WBOYOriginal
2016-06-20 13:04:111370browse

/*<br />*参数分别是开始时间戳,结束时间戳<br />*/<br />function timeList($beginTimeStamp,$endTimeStamp){<br />	if(!is_numeric($beginTimeStamp)||!is_numeric($endTimeStamp)||($endTimeStamp<=$beginTimeStamp)) return '';<br />	$tmp=array();<br />    for($i=$beginTimeStamp;$i<=$endTimeStamp;$i+=(24*3600)){<br />		$tmp['timeStampList'][]=$i;<br />        $tmp['dayList'][]=date('Y年m月d日',$i);<br />		$tmp['dayWeek'][]=getWeek($i);<br />    }<br />	return $tmp;<br />}<br />function getWeek($timestamp){<br />	$timestamp=date('w',$timestamp);<br />	$str='';//http://www.scutephp.com/<br />	switch($timestamp){<br />		case '0':<br />			$str.='周日';<br />		break;<br />		case '1':<br />			$str.='周一';<br />		break;<br />		case '2':<br />			$str.='周二';<br />		break;<br />		case '3':<br />			$str.='周三';<br />		break;<br />		case '4':<br />			$str.='周四';<br />		break;<br />		case '5':<br />			$str.='周五';<br />		break;<br />		case '6':<br />			$str.='周六';<br />		break;<br />	}<br />	return $str;<br />}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn