-5

In my database I have date information stored with the format Y-m-d H:i:s.

For example, there is a datetime with the value 2020-03-14 11:00:00

Using PHP, how do I reformat the data and echo it so that it reads:

"Saturday 14th of March 2020 11:00 AM"

Thanks in advance for looking into my question

  • The DateTime class method [`format`](https://www.php.net/manual/en/datetime.format.php) offers lots of options for date and time formatting. – El_Vanja Mar 15 '20 at 21:42
  • 2
    Does this answer your question? [Convert a date format in PHP](https://stackoverflow.com/questions/2487921/convert-a-date-format-in-php) – John Mar 16 '20 at 00:35

1 Answers1

0

Use this

$DatabaseDateTime = "2020-03-14 11:00:00";

echo date("l jS \of F Y h:i:s A",strtotime($DatabaseDateTime ));

Let me know if any problem occurs

Razin Abid
  • 349
  • 3
  • 15