PHP How to change date format from variable
im currently pulling data from my database along with a date via variable. The code im using is this
echo "".$row["firstname"]." ".$row["lastname"]." thinks that it will happen on ".$row["date"]."";
the results are being displayed as : bobby anderson thinks that it will happen on 2011-09-15开发者_开发知识库
but id like the date to be displayed as Monday 1st August 2011
date('l jS F Y',strtotime($row['date']))
Take a look at the date function, along with strtotime.
You can either use date along with strtotime, or you can use the date_create_from_format method (date_create_from_format example):
echo DateTime::createFromFormat( "Y-n-j", $row['date'])
->format( 'l jS F Y' );
(an now strtotime)
echo date('l jS F Y',strtotime($row['date']));
精彩评论