how to conver the 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
qumar
Forum Commoner
Posts: 29
Joined: Wed Nov 01, 2006 8:20 am

how to conver the date

Post by qumar »

hi,
how to conver the date.
2007-10-15. i am getting the date from the database.i want convert this date to October 15, 2007.how can i convert. give some idea. please help to me.

thanks,
qumar.
User avatar
Josh1billion
Forum Contributor
Posts: 316
Joined: Tue Sep 11, 2007 3:25 pm

Post by Josh1billion »

Are you able to get a timestamp of the original date? If so, you can pass that timestamp as a second argument to date() and date() will format that timestamp into the specified format. If you don't have a timestamp, it may be possible to generate one based off of "2007-10-15", but I'm not sure if that might be more trouble than it's worth.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

Select date_format(my_date,'%M %d, %Y') from `tbl` limit 1;
date_format()


You can also do this with just php also..

Code: Select all

echo date('M d,Y',strtotime('2007-10-15'));
User avatar
Josh1billion
Forum Contributor
Posts: 316
Joined: Tue Sep 11, 2007 3:25 pm

Post by Josh1billion »

Hmm after reading Zoxive's post, ignore the last sentence of my last post and use strtotime() to get that timestamp.
Post Reply