如何使用PHP获取年份?

2022-08-30 23:54:08

可能的重复:
我如何使用PHP来获取当前年份?

今年是2009年,明年是2010年。


答案 1

查看函数 date() 和 strtotime():

echo date('Y');
echo date('Y', strtotime('+1 year'));

答案 2

您可以使用日期函数提取日期的一部分:

$year = date("Y"); // get the year part of the current date
$nextYear = $year + 1;

在此处运行代码段


推荐