时间:2021-07-01 10:21:17 帮助过:20人阅读
function getWeek($day){ $days = array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'); $day = explode('-',$day); return $days[date('w',mktime(0,0,0,$day[1],$day[2],$day[0]))];}
这个意思?
function getWeek($day){ $days = array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'); return $days[date('w', strtotime($day))];}$date = '2014-09-29';if($w = date('w', strtotime($date))) $date = date('Y-m-d', strtotime("-$w day $date"));for($i = 0;$i < 7;$i++){$day = date('Y-m-d',strtotime("$i day $date"));echo $day."(".getWeek($day).")\n";}
这个意思?
function getWeek($day){ $days = array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'); return $days[date('w', strtotime($day))];}$date = '2014-09-29';if($w = date('w', strtotime($date))) $date = date('Y-m-d', strtotime("-$w day $date"));for($i = 0;$i < 7;$i++){$day = date('Y-m-d',strtotime("$i day $date"));echo $day."(".getWeek($day).")\n";}
我理解成楼主想要这周的周一到周日。。。
header("Content-Type: text/html; charset=utf-8");
$timestamp=time();
$is_return_timestamp=false;
static $cache ;
$id = $timestamp.$is_return_timestamp;
if(!isset($cache[$id])){
if(!$timestamp) $timestamp = time();
$monday_date = date('Y-m-d', $timestamp-86400*date('w',$timestamp)+(date('w',$timestamp)>0?86400:-/*6*86400*/518400));
if($is_return_timestamp){
$cache[$id] = strtotime($monday_date);
}else{
$cache[$id] = $monday_date;
}
}
$Monday=strtotime($cache[$id]);
$Tuesday=$Monday+3600*24*1;
$Wednesday=$Monday+3600*24*2;
$Thursday=$Monday+3600*24*3;
$Friday=$Monday+3600*24*2;
$Saturday=$Monday+3600*24*6;
$Sundany=$Monday+3600*24*6;
echo $cache[$id].'周一
' ;
echo date("Y-m-d",$Tuesday).'周二
';
echo date("Y-m-d",$Wednesday).'周三
';
echo date("Y-m-d",$Thursday).'周四
';
echo date("Y-m-d",$Friday).'周五
';
echo date("Y-m-d",$Saturday).'周六
';
echo date("Y-m-d",$Sundany).'周日
';
?>
$Saturday=$Monday+3600*24*5; 这地方改下。。
function getWeek($day){ $days = array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'); return $days[$day];}for($i=0;$i<7;$i++){ $a=strtotime("+$i day"); $b=getWeek(date('w',$a)); $c=date('y-m-d',$a); echo "20$c$b
";}
2014-09-28星期日2014-09-29星期一2014-09-30星期二2014-10-01星期三2014-10-02星期四2014-10-03星期五2014-10-04星期六