Search code examples
strtotimemktimephp

Difficulty converting date in format yyyy-mm-dd to textual date format like Monday 21 Jan 2012 PHP



I am trying to convert a date in format (yyyy-mm-dd) to a textual date format like Monday 21 Jan 2012 using PHP. I have tried using mktime() function but I'm a novice and I cant figure it out.
Any help will be grealty appreciated.


e.g :-   convert 2012-04-27 => Friday 27 April 2012

Thanks.


Solution

  • You can make use of the DateTime class (which is recommended over strtotime):

    $date = new DateTime($date_string);
    $textual = $date->format("l j M Y");