How to show month from datetime

Hi all,

how can I show month from table. And I want it to be displayed as month name, like January, February, etc.

PHP Code:

//connect to database
$connect = mysql_connect(“localhost”, “root”, “”);
$y = 2007;
$s = 13;
$m = 12;
$d = 4;
$H = 23;
$i = 30;
mysql_query(“INSERT INTO date VALUES (‘$y-$m-$d $H:$i:$s’)”);

    $query = mysql_query("SELECT * FROM date");
    while ($row = mysql_fetch_array($query))

$date = getdate($row[‘datetime’]);
printf(‘%s %d, %d’,$date[‘month’],$date[‘mday’],$date[‘year’]);

$a = getdate();
printf(‘%s %d, %d’,$a[‘month’],$a[‘mday’],$a[‘year’]);


When I run this code I get

Notice: A non well formed numeric value encountered in C:\wamp\www\ utorials\date\date.php on line 17 January 1, 1970


I would suggest making sure your database is using the correct data type for your field. Once that is verified phps date and strtotime functions will take care of the rest.

In your loop replace the code with

echo date(“F”,strtotime($row[‘datetime’]));

Good luck!

$date = '2010/09/26'; 
echo date("l", strtotime("$date"));

MySQL alternative:

Hope it helps.