This isnt as simple as the title makes it sound.
I'm coding my own news script and have now started work on the configuration which is stored in mysql
I can now update the dateformat via the admin and when i add new news the new date format is present on the new item.
My problem is all the old news items still have the old date format and i'm wondering if theres an easy way of fixing this.
I was thinking i should add a piece of code in my news retrieval script to change the date format if it isnt in the currently set format but i'm not sure how to do this!
$date_query=mysql_query("SELECT * FROM config");
$row=mysql_fetch_array($date_query);
$date_format = $row[date_format];
$news_date= date($date_format);
So the above is from my add news code... as you can see it retrieves the date format from the database and enters the date for the current news post in that format.... simple enough
for retrieviing the new i have the query and a loop so that all the news items are displayed in there own little box
<?php
include ('admin/functions/db.php');
db_connect ();
$query=mysql_query("SELECT * FROM news WHERE news_active='1' ORDER BY news_date DESC ");
while ($row=mysql_fetch_array($query)) {
echo"<div class=\"contentBox\">";
echo"<div class=\"BoxTitle\">";
echo $row[news_title];
echo"</div>";
echo"<div class=\"BoxContent\">";
echo $row[news_body];
echo"</div>";
echo"<div class=\"BoxFooter\">";
echo"Posted by ";
echo $row[news_poster];
echo" on the ";
echo $row[news_date];
echo"</div>";
echo"</div>";
echo"<br />";
}
?>
This is part of the news retrival code minus the code for putting news of x pages.
Can anyone suggest the best way of getting all the news to have the same date format... rather than only the latest news having the format updated.
Thanks in advance