与我的代码,我试图使URL到上一个或下一个月的一个按钮点击根据当前的网址。PHP mktime不按预期工作
例如,如果我将URL的末尾设为index?view=list&month=January&year=2014
,那么我希望上一个按钮去index?view=list&month=December&year=2013
。对于1月,它工作正常,但当月份是2月份时,上一个按钮等于2月份,下一个按钮是4月份。
上一个按钮
onclick="location.href='?view=list
&month=<?php echo date("F", mktime(0, 0, 0, date('n', strtotime($_GET['month'])) - 1, 1, $_GET['year'])); ?>
&year=<?php echo date("Y", mktime(0, 0, 0, date('n', strtotime($_GET['month'])) - 1, 1, $_GET['year'])); ?>
下一个按钮
onclick="location.href='?view=list
&month=<?php echo date("F", mktime(0, 0, 0, date('n', strtotime($_GET['month'])) + 1, 1, $_GET['year'])); ?>
&year=<?php echo date("Y", mktime(0, 0, 0, date('n', strtotime($_GET['month'])) + 1, 1, $_GET['year'])); ?>
你需要翻身的一年以及? –
日期('F',13)===“December” –
是的,如果是2014年1月,它应该会翻转到2013年12月 –