You can use either date or strftime .
(您可以使用date或strftime 。)
In this case I'd say it doesn't matter as a year is a year, no matter what (unless there's a locale that formats the year differently?) (在这种情况下,我会说,无论什么年份都是一年都没关系(除非有一个地方以不同的方式格式化年份?))
For example:
(例如:)
<?php echo date("Y"); ?>
On a side note, when formatting dates in PHP it matters when you want to format your date in a different locale than your default.
(另外,在PHP格式化日期时,如果要将日期格式设置为与默认语言不同的语言环境,则这很重要。)
If so, you have to use setlocale and strftime. (如果是这样,您必须使用setlocale和strftime。)
According to the php manual on date: (根据日期的php手册 :)
To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().
(要格式化其他语言的日期,您应该使用setlocale()和strftime()函数而不是date()。)
From this point of view, I think it would be best to use strftime as much as possible, if you even have a remote possibility of having to localize your application.
(从这个角度来看,我认为最好尽可能使用strftime,如果你甚至有可能无法本地化你的应用程序。)
If that's not an issue, pick the one you like best. (如果这不是问题,请选择您最喜欢的那个。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…