2016-02-19 60 views
0

我有PHP的功能,从这个和下周得到日期。除了星期四外,一切都很好 - 星期四的输出是空的。php strtotime星期四不工作

这里是我的代码:

$pondeli1 = date('d.m.Y', strtotime('monday this week')); 
$utery1 = date('d.m.Y', strtotime('tuesday this week')); 
$streda1 = date('d.m.Y', strtotime('wednesday this week')); 
$ctrvtek1 = date('d.m.Y', strtotime('thursday this week')); 
$patek1 = date('d.m.Y', strtotime('friday this week')); 

$pondeli2 = date('d.m.Y', strtotime('monday next week')); 
$utery2 = date('d.m.Y', strtotime('tuesday next week')); 
$streda2 = date('d.m.Y', strtotime('wednesday next week')); 
$ctrvtek2 = date('d.m.Y', strtotime('thursday next week')); 
$patek2 = date('d.m.Y', strtotime('friday next week')); 

和线中的“周四下周”不返回任何东西......

哪里是问题吗?

+0

工作正常,我.... 2016年2月15日 2016年2月16日 2016年2月17日 2016年2月18日 2016年2月19日 2016年2月22日 2016年2月23日 24.02 .2016 25.02.2016 26.02.2016 – devpro

+0

按预期方式工作,以及在phpfiddle.org上 – Aukhan

+2

我删除了我原来的评论; “下周四”应该按[手册](http://php.net/manual/en/datetime.formats.relative.php)工作。 @Aukhan说,你的代码在phpfiddle中工作。 – Egg

回答

2

尝试使用

$ctrvtek2 =strtotime("next Thursday",$ctrvtek1); 
+0

如果明天是星期四,但我希望下周星期四怎么样似乎是作者的情况? – Chris

+0

这个电话会在$ ctrvtek1(这是星期四)之后的下个星期四返回, – Aboulfouz

相关问题