How to echo 2011-01-31 as 31 January 2011?
How I can echo 2011-01-31 as 31 January 2011? The input (2011-01-31) 开发者_如何转开发comes from the database (type: date).
Also is there any option to use locale names for the month?
Edit:
$date = date_create($row['bdate']);
echo date_format($date, 'd F Y'); //31 January 2010
could be solution but date_format
has no option for other languages(?). Is there any solution? Like 31 Ocak 2011
Probably is strftime what you seek.
Example:
echo strftime('%d %B %Y', strtotime($db_entry));
Use strtotime
to convert 2011-01-31
to a timestamp:
echo date( 'd F Y', strtotime( $row['bdate'] ) );
<?php
echo date('d F Y', strtotime("2011-01-31"));
Demo: http://codepad.org/WPe1xCFz
Try using strftime()
$date = strtotime($row['bdate']);
echo strftime('%d %B %Y', $date);
精彩评论