0

I have a datetime field which saves the date in numerical format:

2013-11-23 21:21:31

I want to format this value into Y-m-d H:i:s so that instead of a list of numbers it reads as:

23rd November 2013

with or without the time, doesn't really matter too much.

Is this possible using date() or is that just for submitting data?

Dalían
  • 222
  • 3
  • 4
  • 14

1 Answers1

1

Convert the date string to a timestamp using strtotime() and feed it to date():

echo date('jS F Y', strtotime($dateStringFromDB));

For other available formatting options, refer to the documentation for date().

Amal Murali
  • 75,622
  • 18
  • 128
  • 150