如何让约会时间变成这样?

发布于 2024-10-09 21:07:05 字数 167 浏览 0 评论 0原文

您好,我正在保存来自 rss feed url 的数据。从那以后我就得到了这样的约会时间。

2011 年 1 月 2 日星期日 03:04:02 GMT+5:30

如何使用 php 将此日期更改为 2011 年 1 月 2 日下午 03:04 这种格式? 任何人都知道解决方案请帮助我。

Hi I am saving data from rss feed url. From that me got date time like this.

Sun, 2 January 2011 03:04:02 GMT+5:30

How to change this date to this format 2nd January 2011, 03:04 PM using php?
any body knows the solution please help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南风几经秋 2024-10-16 21:07:05

您可以使用 strtotime 函数来转换现有字符串和 'r ' 说明符到 date 函数,如下所示(看起来您希望它在RFC 2822 格式,如果没有相应调整):

date('r', strtotime("Sun, 2 January 2011 03:04:02 GMT+5:30"));  

顺便说一句,请确保您通过 date_default_timezone_set

You can se the strtotime function to convert the existing string and the 'r' specifier to the date function as follows (looks like you want it in RFC 2822 format, if not tweak accordingly):

date('r', strtotime("Sun, 2 January 2011 03:04:02 GMT+5:30"));  

Incidentally, make sure you're setting your local timezone correctly via date_default_timezone_set, etc.

半山落雨半山空 2024-10-16 21:07:05

以下函数对于获取字符串并获取时间戳非常有用:

将其作为时间戳后,您可以使用 date()。我不是 100% 确定 strtotime() 是否会接受该格式,但它应该接受它,因为它的格式并不含糊。

The following functions are useful for taking a string and getting a timestamp back:

After you have it as a timestamp, you can reformat it using date(). I'm not 100% sure if strtotime() would accept that format, but it should accept it because the format it isn't ambiguous.

就是爱搞怪 2024-10-16 21:07:05

echo date("js FY, h A", strtotime($oldDate));

echo date("js F Y, h A", strtotime($oldDate));

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文