sando Posted September 12, 2007 Share Posted September 12, 2007 Hi All, Im having a bit of trouble with a blog im working on. It currently outputs the date of posting as: 2007-09-01 (Year, Month, Day) I need it to output the date as 01-09-2007 (Day, Month, Year) <?include("header.php"); $sql1="select * from blog"; $result1=db_query($sql1); $num=mysql_num_rows($result1); $reccnt= mysql_num_rows($result1); if($order_by=='') { $order_by='announcement_date'; $order_by2='desc'; } ?> <TABLE cellspacing='2' cellpadding='0' border='0'> <?while($row=mysql_fetch_array($rs)){?> <TR> <td class='normaltextbold'> <?=$row[announcement];?> </td> </TR> <TR> <td class='normaltextbold'> <?=$row[announcement_date];?></td> </TR> <tr bgcolor='#FFCFEE'> <td colspan='2'><img src='images/spacer.gif' height='1' colspan='2'></td> </tr> <tr > <td ><img src='images/spacer.gif' height='5'></td> </tr> <?}?> <tr bgcolor='#FFFFFF'><td colspan='4'><?include("admin/paging.inc.php");?></td></tr> </TABLE> A bit of help would be greatly appreciated! I'm new to working with PHP, and the blog was originally developed by a different person. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/69021-solved-php-date-help/ Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 list($year, $month, $day) = split("-", $row[announcement_date]; echo "$day-$month-$year"; Quote Link to comment https://forums.phpfreaks.com/topic/69021-solved-php-date-help/#findComment-346961 Share on other sites More sharing options...
Barand Posted September 12, 2007 Share Posted September 12, 2007 use date() function for formatting dates and times. In this case you want <?= date('d-m-Y', strtotime($row['announcement_date'])) ?> Quote Link to comment https://forums.phpfreaks.com/topic/69021-solved-php-date-help/#findComment-346962 Share on other sites More sharing options...
sando Posted September 12, 2007 Author Share Posted September 12, 2007 Thanks a lot for the help guys. Now solved. Quote Link to comment https://forums.phpfreaks.com/topic/69021-solved-php-date-help/#findComment-346966 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.