PHP:strftime(),date()还是DateTime,哪个更好? [英] PHP: strftime(), date() or DateTime, Which is better?

查看:211
本文介绍了PHP:strftime(),date()还是DateTime,哪个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道PHP中是否有使用 strftime()超过 date()或相反亦然。



我下载的课程使用了 strftime()。但是,由于它不支持某些系统上的所有时间格式,我想将其更改为使用 date()。我想知道在使用其中是否存在任何重大区别或优势。



如果 strftime()仅支持该服务器c库支持的日期格式? date()有类似的限制吗?

解决方案

我想你'code> date()比 strftime()



date()只能以英文返回月/日名字,无法为您提供其他语言的翻译。



性能影响应该可以忽略不计。



如果你决定去日期路线,我真的建议使用 DateTime ,使大多数日期和时间相关操作比使用原始的程序功能更容易。


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 over 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.

这篇关于PHP:strftime(),date()还是DateTime,哪个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆