Page 1 of 1

Change format of date

Posted: Sat Dec 26, 2009 9:04 pm
by dheeraj
Good Morning guys, i have problem in converting the date (which is in numerical format) in text format....
suppose i have a date..
$date = 12/01/2009
so its output should be, 12th january 2009 (means i have to just convert the month only not the date or year)

Thanx

Re: Change format of date

Posted: Sat Dec 26, 2009 9:28 pm
by requinix
Convert the /s to -s, then run it through strtotime():

Code: Select all

$date = "12/01/2009";
 
$date = str_replace("/", "-", $date);
echo date("r", strtotime($date));