Php strtotime显示1970年1月1日,作为新年变更后的结果

Php strtotime显示1970年1月1日,作为新年变更后的结果,php,timestamp,strtotime,Php,Timestamp,Strtotime,我正在使用strotime显示下周星期二到星期五的日期'd.m.Y'。 2017年一切顺利,但从2018年起,我得到了1970年1月1日的成绩。找不到问题的答案。代码如下: <?php date_default_timezone_set('UTC'); $week = date('W'); $yearnow = date('Y'); $nextweek = date('W')+1; $timestamp_tu = strtotime("{$yearnow}-W{$nextweek}-2"

我正在使用strotime显示下周星期二到星期五的日期'd.m.Y'。 2017年一切顺利,但从2018年起,我得到了1970年1月1日的成绩。找不到问题的答案。代码如下:

<?php
date_default_timezone_set('UTC');
$week = date('W');
$yearnow = date('Y');
$nextweek = date('W')+1;

$timestamp_tu = strtotime("{$yearnow}-W{$nextweek}-2");
$date_tu = date('d.m.Y', $timestamp_tu);
$timestamp_we = strtotime("{$yearnow}-W{$nextweek}-3");
$date_we = date('d.m.Y', $timestamp_we);
$timestamp_th = strtotime("{$yearnow}-W{$nextweek}-4");
$date_th = date('d.m.Y', $timestamp_th);
$timestamp_fr = strtotime("{$yearnow}-W{$nextweek}-5");
$date_fr = date('d.m.Y', $timestamp_fr);

?>

但是如果我使用实际的$week而不是$nextweek,则显示的日期是正确的。
谢谢。

您可以通过以下方式实现:

date('d.m.Y', strtotime('next week tuesday'));
date('d.m.Y', strtotime('next week wednesday'));
date('d.m.Y', strtotime('next week thurday'));
date('d.m.Y', strtotime('next week friday'));

PHP有更好的处理日期的工具。我建议使用它们。我甚至不知道“strotime”(“2018-W3-2”)一开始是如何工作的。。。还有@johncode所说的。是的,必须更改代码:$date_tuday=date(“d.m.Y”),strotime(“星期二”,“下周”);我过去没有考虑过代码,因为直到现在错误发生,他才生成错误。谢谢你们的帮助