如何将日期转换为与我的数据库不同的格式? [重复]

This question already has an answer here:

In my database, dates are stored in this format:

2013-03-14

I want to show dates on my web page formatted as:

2013-march-14

I have a lot of date data already stored in my database, so it's not possible to change my database. How can I do this conversion?

</div>

You can do this

Via MySQL

SELECT DATE_FORMAT(datecolumn, '%Y-%M-%d') FROM table

Via PHP

$date = '2013-03-14';
echo date("Y-F-d", strtotime($date));

Output

2013-march-14

Use the MySQL built-in DATE_FORMAT function, with the specifiers '%Y-%M-%d' to format the date parts the way you want:

SELECT DATE_FORMAT(datefield, '%Y-%M-%d')
...

SQL Fiddle Demo

If you wanted to do this on PHP you could use the date function

$d = '2013-03-04';
echo date("Y-M-d", strtotime($d));  //2013-Mar-04