Welcome to WebmasterWorld Guest from 54.145.235.72

Forum Moderators: coopster & jatar k

Date conversion

   
1:41 pm on Mar 14, 2006 (gmt 0)

10+ Year Member



Hi,

What I am trying to achieve is that if you get a month number, I would like to convert into month name i.e. March.

Now I've had a go, but it doesn't quite work because its not looping correctly, what I mean, it displays 'March'. Any ideas anyone?

Thanks

W.

<?
$result=mysql_query("SELECT distinct MONTH(story_date) as month,YEAR(story_date) as year
FROM tbl_news WHERE tbl_news.ncid=$ncid
order by month asc");
while (list($DBmonth,$DByear)=mysql_fetch_row($result))
{
echo $DBmonth.'<br><br>';
$unixdate=strtotime ($DBmonth);

$date_time_array=getdate($unixdate);

$month_c=$date_time_array["month"];

$month_title=$month_c;

echo $month_title.'<br>';

}
?>

1:57 pm on Mar 14, 2006 (gmt 0)

10+ Year Member



Okay I have found a solution:

<?
$result=mysql_query("SELECT distinct MONTH(story_date) as month,YEAR(story_date) as year
FROM tbl_news WHERE tbl_news.ncid=$ncid
order by month asc");
while (list($DBmonth,$DByear)=mysql_fetch_row($result))
{
$date = date('F', mktime(0, 0, 0, $DBmonth));
echo $date .'<br>';
}
?>

Thanks

W. :o)

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month