Search code examples
phpdate-conversion

How do I convert a date in PHP?


How can I convert this date:

2009-12-21 10:38:07

to a more readable date, like 22 December 2009 - 10:38 ?


Solution

  • You can use the date function with strtotime:

    $strDate = "2009-12-21 10:38:07";
    echo date('d F Y - H:i', strtotime($strDate));