如何将日期从 yyyy-mm-dd 转换为 Month(in words) day year? [英] How to convert a date from yyyy-mm-dd to Month(in words) day year?

查看:35
本文介绍了如何将日期从 yyyy-mm-dd 转换为 Month(in words) day year?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法转换此日期.我想要的是将 yyyy-mm-dd 格式的日期转换为月日年.我怎样才能做到这一点?下面是我的代码.

I have trouble in converting this date. What I want is to convert the date formated in yyyy-mm-dd into Month day year. How can I achieve this? below is my code.

$news = mysql_query("SELECT * FROM tblupcomingevents WHERE date >= CURRENT_DATE() LIMIT 5") or die(mysql_error());
while($row = mysql_fetch_array($news))
{?>
<?php echo $row ["date"] ?>
<?php echo $row ["place"] ?>
<?php
}
?>

推荐答案

使用 PHP date 函数重新格式化:

Use the PHP date function to reformat it:

echo date('F j, Y',strtotime($row['date']));  // January 30, 2015, for example.

有关更多格式选项,请参阅日期.

See date for many more formatting options.

这篇关于如何将日期从 yyyy-mm-dd 转换为 Month(in words) day year?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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