如何将yyyy-mm-dd格式转换为文本格式?(例如:2011年8月6日)


How to convert yyyy-mm-dd format to text format? (Ex: August 6, 2011)

如何在php中将日期格式从2011-08-06转换为2011年8月6日?

这应该可以满足您的需求:

<?php
$mydate = '2011-08-06';
$datestr = date('F j, Y', strtotime($mydate));
echo $datestr;

看到date() <一口>文档strtotime() <一口>文档

格式如下:

date("F j, Y", strtotime($date));

参见date()

createFromFormat创建DateTime对象,用format吐出

$date = "2011-08-06";
echo date("F j, Y",strtotime($date));