开发者

PHP: strftime(), date() or DateTime, Which is better?

开发者 https://www.devze.com 2023-03-03 19:55 出处:网络
I am curious to know if there is any advantage in PHP of using strftime() over date() or vice versa.

I am curious to know if there is any advantage in PHP of using strftime() over date() or vice versa.

A class I downloaded used the strftime(). However, since it does not support all time formats on some systems, I want to change it to use date() instead. I was wondering if there are any major differances or advantages in using one ov开发者_运维技巧er the other.

What about the fact that strftime() only supports date formats that are supported by that servers c library? Does date() have any similar restrictions?


I think you'll find date() is more widely used than strftime()

date() is only able to return month/day names in English and won't be able to give you translations for other languages.

The performance implications should be negligible.

If you decide to go the date route I'd really recommend using DateTime which makes most date and time related operations easier than using the original procedural functions.


is any advantage in PHP of using strftime() over date()

From the date manual page:

To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().

0

精彩评论

暂无评论...
验证码 换一张
取 消