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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...