Current date is 30 October 2017
This code:
date("F",strtotime("-8 Month"))
Returns "March" where it should be February.
php snippet: http://sandbox.onlinephpfunctions.com/code/cfba4f420e9f76026be0286b52d780d0a75b8cd3
Yep, that appears to be the case...
To get around that you could use...
echo date("F",strtotime("first day of -8 Month"));
That's from some discussion on http://php.net/manual/en/function.strtotime.php
This is happening because February has 28 or 29 days. Use this hack and you will get the correct date
echo date("F",strtotime("first day of -8 Month"));
感谢您的回答-我设法使用以下方法解决了该问题:
strtotime(date('Y-m')." -8 Month")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.