#3 jake
$temp_date = date('Y-m-d', strtotime($this->startday) + 1*24*60*60*$i);
改成:
$temp_date = date('Y-m-d N', strtotime($this->startday) + 1*24*60*60*$i);
看看
2012-02-13 21:29:53
#4 ry.china
jake 发表于 2012-2-13 21:29 
$temp_date = date('Y-m-d', strtotime($this->startday) + 1*24*60*60*$i);
改成:
老大经过你的提醒,我现在代码这样写
$temp_date = date('Y-m-d',strtotime($this->startday) + 1*24*60*60*$i);
$week_index = date('w',strtotime($this->startday) + 1*24*60*60*$i);
echo $temp_date." ".$week_index."
";
最后的执行结果是
2012-02-14 2
2012-02-13 1
2012-02-12 0
2012-02-11 6
2012-02-10 5
2012-02-09 4
2012-02-08 3
2012-02-07 2
2012-02-06 1
2012-02-05 0
2012-02-04 6
2012-02-03 5
2012-02-02 4
2012-02-01 3
2012-01-31 2
2012-01-30 1
2012-01-29 0
2012-01-28 6
2012-01-27 5
2012-01-26 4
2012-01-25 3
2012-01-24 2
2012-01-23 1
2012-01-22 0
2012-01-21 6
2012-01-20 5
2012-01-19 4
2012-01-18 3
2012-01-17 2
2012-01-16 1
2012-01-15 0
2012-01-14 6
2012-01-13 5
2012-01-12 4
2012-01-11 3
2012-01-10 2
2012-01-09 1
2012-01-08 0
2012-01-07 6
2012-01-06 5
2012-01-05 4
2012-01-04 3
2012-01-03 2
2012-01-02 1
2012-01-01 0
我原来是这样写的
$temp_date = date('Y-m-d',strtotime($this->startday) + 1*24*60*60*$i);
echo $temp_date." ".date('w', $temp_date)."
";
这个就有点悲剧了,是php的什么机制吧,这个还没弄懂;
2012-02-14 20:08:50
#5 jake
date第二个参数,是时间戳。
$temp_date = date('Y-m-d',strtotime($this->startday) + 1*24*60*60*$i); // 这里的第二个参数是时间戳没错
echo $temp_date." ".date('w', $temp_date)."
"; // 这里第二个参数就不是时间戳了。
也就是说,没有什么机制,只是date的第二个参数用错了~~~
2012-02-14 20:25:41