PHP日期-如何添加字符串以分隔日期和时间 [英] PHP Date - How to add a string to separate date and time
本文介绍了PHP日期-如何添加字符串以分隔日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示日期和时间格式,例如 5月23日下午12:30
。
我在PHP手册中看到并发现:
I want to display date and time format something like this "May 23 at 12:30pm"
.
I saw in PHP manual and found:
// Prints something like: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A');
修改后,我设法得到
echo date('M j \of h:i a');
这给了我 5月23日下午12:30
,但是当我将的
它给了我 of
替换为 5月23日a23 08:26下午 。
我什么都不是
推荐答案
您需要转义 a
和 t
因为在 date()
echo date('M j \a\t h:i a');
这篇关于PHP日期-如何添加字符串以分隔日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文