我可以找到上个月的最后一个星期一,但我还需要两个月前的最后一个星期一?
strtotime("last Monday of June 2015") //gives previous month's last Monday
如何找到-2个月的最后一个星期一?
我将以编程方式使用
试试这个:
// Past
strtotime("last Monday of -2 months");
// Future
strtotime("last Monday of +2 months");
工作像一个魅力!PHP的strtotime
非常聪明
在我看来很脏,但这行得通
$no_months = -2; // Number of months from now
echo date('d/M/Y' , strtotime('Last monday of ' . date('M Y', strtotime($no_months . ' months'))));
本质上,这只是动态地创建"June 2015","May 2015"部分的原始字符串,这取决于你在var中设置的月的负/正值。