微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 增加日期日期的问题

我试着在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

代码https://3v4l.org/jmT9a

任何帮助或建议将不胜感激

解决方法:

问题原因: – 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.

Som-d-Y是无法识别的格式,同时为PHP日期添加天数.

如下所示: –

<?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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐