【发布时间】:2016-05-30 20:49:49
【问题描述】:
为什么
<?php echo date("m/d/Y" strtotime('second Wednesday June-2016')) ?>
输出 2016 年 6 月 15 日而不是 2016 年 6 月 8 日?
这是我想出的解决方法 --- 不是很雄辩:
<?php
months = array( 1=>'Jan',2=>'Feb',3=>'Mar',4=>'Apr',5=>'May',6=>'Jun',7=>'Jul',8=>'Aug',9=>'Sep',10=>'Oct',11=>'Nov',12=>'Dec');
$year = "2016";
$month = "06";
$smonth=$months[(int)$month];
$tstr=$month."/01/".$year;
$dow=date("D",strtotime($tstr));
if ( $dow == "Wed" ) {
$nstr="first";
} else {
$nstr="Second";
}
$edate= date("m/d/Y", strtotime($nstr.' Wednesday '.$smonth.'-'.$year));
echo $edate."<br>";
?>
【问题讨论】:
-
代替
second尝试使用2