PHP日期格式到月份名称和年份 [英] PHP Date Format to Month Name and Year

查看:148
本文介绍了PHP日期格式到月份名称和年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个日期数据:

20130814

如何获取字符串输出: PHP)

How to get string output like this : (in PHP)

2013年8月

推荐答案

echo date('F Y', strtotime('20130814'));

这应该是诀窍。

编辑:您的日期是一个字符串格式。为了能够格式化它,您首先需要将其更改为一个日期本身,这就是strtotime进入的地方。这是一个奇妙的功能,可将几乎任何合法的日期表达式转换为日期本身。那么我们实际上可以使用date()函数将输出格式化成你想要的。

You have a date which is in a string format. To be able to format it nicelt, you first need to change it into a date itself - which is where strtotime comes in. It is a fantastic feature that converts almost any plausible expression of a date into a date itself. Then we can actually use the date() function to format the output into what you want.

这篇关于PHP日期格式到月份名称和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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