如何在PHP中重新格式化日期? [英] How to reformat date in PHP?

查看:148
本文介绍了如何在PHP中重新格式化日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从数据库中拉出各种职位的日期。日期格式如下:

  2009-08-12 

数字年 - 数字月 - 数字日

如何将这些日期重新格式化为更友好的用户,如:

  2009年8月12日

数字月数字日期,数字年
/ pre>

假设从mysql数据库获取的日期存储在一个变量中:

  $ date = $ row ['date_selected']; 


解决方案

date ,Y,strtotime($ input))


I am pulling the dates of various posts from a database. The dates are in the following format:

2009-08-12

Numeric Year - Numeric Month - Numeric Day

How can I reformat these dates to something more user friendly like:

August 12, 2009

Numeric Month Numeric Date, Numeric Year

Assuming that the date gotten from the mysql database is stored in a variable called:

$date = $row['date_selected'];

解决方案

date("F d, Y", strtotime($input))

这篇关于如何在PHP中重新格式化日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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