2016-01-19 48 views
0

使用strtotime WEEK获得1970年的第00周?我正在使用一个大功能,所以无法在这里发布。使用strtotime()得到1970年的时候?

我期待通过周获得周天。

for ($weekNumber=00;$weekNumber<=$weekEnd;$weekNumber++) 
{ 
    runTheScript($weekNumber,$month,$weekStart,$weekEnd,$link,$limit,$standardTarget,0,$year); 
} 

我的结果 -

周,开始,结束,天

49 2015年12月1日2015年12月6日6
50 2015年12月7日2015年12月13日7
51二○一五年十二月十四日20 Dec 2015 7
52 2015年12月27日2015年7月27日
53 2015年12月31日2015年12月31日4

未来

00 1月1日1970年 2016年1月3日3
01 2016年1月4日2016年1月10日7
02 2016年1月11日2016年1月17日7
03 2016年1月18日2016年1月24日7
04月25日2016年1月2016年1月31日7

我如何设置周

$weekStart = date('W',strtotime($year . '-' . $month. '-01'));#$_REQUEST['start']; 
$weekEnd = date('W',strtotime($year . '-' . $month. '-'.date('t',strtotime($year . '-' . $month. '-01'))));#$_REQUEST['end']; 
#if ($weekStart > $weekEnd) $weekStart = 1; 

回答

1

这是因为没有周0 0.去年的第53周是12月28日(星期一)。下周是1月4日(星期一)的第01周。你应该改变你的循环从weekNumber = 01开始,并将“大于或等于”改为“大于”

for ($weekNumber=1;$weekNumber<$weekEnd;$weekNumber++) 
+0

摆脱那个'0'。 –

+0

@KarolyHorvath感谢 – plhyhc

+1

嗨@ user5554551如果这个或任何答案已经解决您的问题,请(http://meta.stackexchange.com/q/5234/179419)通过单击复选标记考虑[接受它。这向更广泛的社区表明,您已经找到了解决方案,并为答复者和您自己提供了一些声誉。没有义务这样做。 – plhyhc