I want to change the look of this date format from:
2012-01-01
to
1 January 2012
My Code:
<?php foreach($funds as $fund) { ?>
<li><?php echo $fund['fund']; ?><span class="price"><div align="center" class="h1"><strong><br />
R<?php echo $fund['price']; ?></strong><br />as at <br />
<?php echo $fund['date']; ?></div></span></li>
<?php } ?>
refer this http://php.net/manual/en/function.date.php
<?php
$date = '2012-01-01';
echo date("j F Y" , strtotime($date));
?>
$date = new DateTime('2012-01-01');
echo $date->format('d F Y');
Edit
<?php foreach($funds as $fund) { ?>
$date = new DateTime($fund['date']);
<li>
<?php echo $fund['fund']; ?>
<span class="price">
<div align="center" class="h1"><br />
<strong>R<?php echo $fund['price']; ?></strong><br />
as at <br />
<?php echo $date->format('d F Y'); ?>
</div>
</span>
</li>
<?php } ?>
try this query
select date_format(dateField,'%d %M %Y') from tableName;
-- Update
$records=mysql_query("select fund,price,date_format(date, '%d %M %Y') as date_formatted from fund");
foreach( $records as $row)
{
echo $row['fund'];
echo $row['price'];
echo $row['date_formatted'];
}