Change format of date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

Change format of date

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Change format of date

Post 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));
Post Reply