将每年特定日期的显示年份更改为下一年


Changing displayed year to the next year on a specific date each year

大家好,我有一个进退两难的问题。我有一个应用程序,需要更新到2017-2018年,显示在2016年10月1日上午12点的按钮上。它必须保持这种状态,直到明年的10月1日,它将再次更新到2018-2019年。如何在php中写这个?

你可以试试

//the year from is the current year
$yearFrom = date("Y");
//if it's october or later, make the year from NEXT year
if (date("n")>=10) $yearFrom++;
//the year to is always the year after the year from
$yearTo = $yearFrom + 1;

然后在你的按钮里面

echo $yearFrom."-".$yearTo;