我试着在m-d-Y中增加天数(60)但计算错误的一天.它被认为是d-m-y格式.
echo "Today is :: ".date("m-d-Y");
echo "\n";
echo $DateEnd = date('m-d-Y', strtotime(date("m-d-Y") . ' +60 day'));
输出是::
Today is :: 11-07-2017
End date is :: 09-09-2017
任何帮助或建议将不胜感激
解决方法:
问题原因: – strtotime()注意事项: –
Dates in the m/d/y or d-m-y formats are disambiguated by looking
at the separator between the varIoUs components: if the separator is a
slash (/), then the American m/d/y is assumed; whereas if the
separator is a dash (-) or a dot (.), then the European d-m-y format
is assumed. If, however, the year is given in a two digit format and
the separator is a dash (-, the date string is parsed as y-m-d.
如下所示: –
<?PHP
echo "Today is :: ".date("m-d-Y");
echo "\n";
echo $DateEnd = date('m-d-Y', strtotime(date("y-m-d") . '+60 days'));
Outpit:-https://eval.in/894300
另请查看Php date formats