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

前端 未结 2 1518
无人及你
无人及你 2021-02-07 00:46

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 strft

相关标签:
2条回答
  • 2021-02-07 01:15

    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.

    0 讨论(0)
  • 2021-02-07 01:32

    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 讨论(0)
提交回复
热议问题