如何用PHP获取年份数?

omg*_*omg 14 php date

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

2009年是今年,2010年是明年.

NSS*_*Sec 38

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

echo date('Y');
echo date('Y', strtotime('+1 year'));
Run Code Online (Sandbox Code Playgroud)


CMS*_*CMS 15

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

$year = date("Y"); // get the year part of the current date
$nextYear = $year + 1;
Run Code Online (Sandbox Code Playgroud)

此处运行代码段.


小智 8

<?php
$date="2010-04-30";
$y = date('Y',strtotime($date));
echo $y; 
?>
Run Code Online (Sandbox Code Playgroud)