Page 1 of 1

how to conver the date

Posted: Wed Oct 17, 2007 9:53 am
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.

Posted: Wed Oct 17, 2007 10:00 am
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.

Posted: Wed Oct 17, 2007 10:02 am
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'));

Posted: Wed Oct 17, 2007 10:17 am
by Josh1billion
Hmm after reading Zoxive's post, ignore the last sentence of my last post and use strtotime() to get that timestamp.