homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Date conversion
woldie




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

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>';

}
?>

 

woldie




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

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)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved