I am having trouble formating the dates that are being returned from my mySQL database. 
Here is the code that I am trying to use: 

```
<?php
function get_gold_time()
{
     $goldquery = mysql_query("SELECT * FROM metal_price WHERE metal= 'GOLD' LIMIT 0, 96"); 

         while($result = mysql_fetch_array( $goldquery )) 
 { 

        echo "'" . date_format($result['time'], 'jS ,g A') . "'" . ", " ;  
 } 

         }
?>

```

This is the error I receive:

Warning: date\_format() expects parameter 1 to be DateTime, string given in /home/bellsnet/public\_html/chart.php on line 128
'', 

Without the date format my code looks like this:

```
<?php
function get_gold_time()
{
     $goldquery = mysql_query("SELECT * FROM metal_price WHERE metal= 'GOLD' LIMIT 0, 96"); 

         while($result = mysql_fetch_array( $goldquery )) 
 { 

        echo "'" .$result['time'] . "'" . ", " ;  
 } 

         }
?>

```

And is returning my values as follows:

```
'2011-08-10 01:15:02', '2011-08-10 01:00:02', '2011-08-10 00:45:02', '2011-08-10 00:30:02', '2011-08-10 00:15:02', '2011-08-10 00:00:02', '2011-08-09 23:45:03', '2011-08-09 23:30:02', '2011-08-09 23:15:02', '2011-08-09 23:00:03', '2011-08-09 22:45:02', '2011-08-09 22:40:22', '2011-08-09 22:30:02', '2011-08-09 22:15:02', '2011-08-09 22:13:41', '2011-08-10 02:00:02', '2011-08-10 01:45:02', '2011-08-10 01:30:02', '2011-08-10 02:15:02', '2011-08-10 02:30:02', '2011-08-10 02:45:02', '2011-08-10 03:00:02', '2011-08-10 03:15:03', '2011-08-10 03:30:03', '2011-08-10 03:45:03', '2011-08-10 04:00:03', '2011-08-10 04:15:01', 

```

Any Help WOuld be greatly appreciated! Ive been tinking around with this for hours.
['https://Stackoverflow.com/questions/7043502', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/766840/']
try date()

```
<?php
function get_gold_time()
{
     $goldquery = mysql_query("SELECT * FROM metal_price WHERE metal= 'GOLD' LIMIT 0, 96"); 

         while($result = mysql_fetch_array( $goldquery )) 
 { 

        echo "'" . date('jS ,g A', strToTime($result['time'])) . "'" . ", " ;  
 } 

         }
?>

```

or use DATE\_FORMAT() directly in MYSQL query:

<http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format>
It would be far better to just format the date in MySQL through DATE\_FORMAT() as it would be quite a bit faster and give you what you want. 

See this: <http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format>