从数据库格式化日期? [英] Format date from database?

查看:121
本文介绍了从数据库格式化日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



2009-10-14T19:00:00



我想以两种不同的方式进行格式化。



第一个:F d,Y
第二个h: m(12小时格式)



我尝试的一切返回1969年12月...帮助?我感到很困惑...

解决方案

通常代码只是:



回音日期('F d,Y h:mA',strtotime('2009-10-14 19:00:00'));

  

请注意,如果 strtotime()确定日期,它返回时间为 1/1/1970 00:00:00 GMT


When I pull the date out of the db, it comes back like this:

2009-10-14T19:00:00

I want to format it in two different ways...

The first: F d, Y The second h:m (12 hour format)

Everything I try returns December 1969... Help?! I feel so confused...

解决方案

Normally the code is just:

echo date('F d, Y h:mA', strtotime('2009-10-14 19:00:00'));

Note that if strtotime() can't figure out the date, it returns the time as 1/1/1970 00:00:00 GMT.

这篇关于从数据库格式化日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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