-4

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?

Michael Petrotta
  • 58,479
  • 27
  • 141
  • 176
User
  • 360
  • 3
  • 4
  • 18

3 Answers3

0

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

Mahmoud Gamal
  • 75,299
  • 16
  • 132
  • 159
0

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
rantsh
  • 596
  • 9
  • 29
0

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
Sumit Bijvani
  • 8,012
  • 17
  • 49
  • 82