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
  • 210
  • 2
  • 4
  • 13

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
  • 73,160
  • 18
  • 123
  • 143