Hi all !! I hope someone will loose some time to help me....😃
I found a script to upload news to my website and add comments to it... I'm working to fit my desires but I have some troubles with the date format. I'm italian and I would like to have a date as
20.15 04/02/2003 or something similar instead of having a Monday,. 03rd February 2003...
now I found that the date is coming from a common.inc.php file
here is the code and the comments of the author:
$thedate = gmdate(" l, jS F");
/ the line above gets the GMT time, and converts it into a lowercase date string (check out the date function in the php manual).
if you don't want the date lowercase, remove the date in lowercase, remove the "strtolower(" from the front and the additional ")" at the end. -------> I DID IT !!!!!
NOTE : admitedly, this system is a bit more inflexible than putting the date in as a unix timestamp, and then formatting it, because you could in the future change
how you want your dates displayed. if you want to change, then make the above line into:
$thedate = now();
and on the index and comments page, put this line after results have been extracted:
$thedate = date(" l, jS F", $thedate); and play around with that to get your desired format./
this is part of the code of the named index.php page
$query = "
SELECT $maintable.id, $maintable.thedate, $maintable.nome, $maintable.topic, $maintable.entry, count($commentstable.id) AS comments
FROM $maintable
LEFT OUTER JOIN $commentstable
ON $maintable.id = $commentstable.id
$sortby
GROUP BY $maintable.id
ORDER BY $maintable.id DESC
$limit";
$result = mysql_query($query) or die("<strong class=black-large>Whoops! Something wrong happened to the my database! It would be nice if you emailed <a href=mailto:$webmaster>me</a> and told me!</strong>");
if ($result) {
echo "<table border=0 cellspacing=0 cellpadding=5 width=$width align=center>";
while ($r = mysql_fetch_array($result)) {
extract($r);
$entry = nl2br($entry);
echo "
<tr bgcolor=ffffff><td><strong class=black-small>$nome</strong></td></tr>
<tr bgcolor=ffffff><td><strong class=black-small>$topic</strong></td><td align=right><strong class=black-small>$thedate</strong></td></tr>
<tr bgcolor=ffffff><td colspan=2><small class=black-small>$entry</small><br></td></tr>
<tr bgcolor=ffffff><td><small class=black-small>» <a href=\"javascript:popupwin('comments.popup.php?id=$id',250,530)\">Commenta questa news...</a></small></td><td align=right><small class=black-small><a href=\"diary.comments.php?id=$id\">Leggi i commenti</a>, ($comments) fatti finora.</small></td></tr>
<tr bgcolor=ffffff><td colspan=2><hr color=990000 size=1 width=100%></td></tr>
";
}
echo "</table><br>";
mysql_free_result($result);
}
$query2 = "SELECT month FROM $maintable GROUP BY month ORDER BY id";
$result2 = mysql_query($query2) or die("<strong class=black-large>Whoops! Something wrong happened to the my database! It would be nice if you emailed <a href=mailto:$webmaster>me</a> and told me!</strong>");
if ($result2) {
echo "<form><table border=0 cellspacing=0 cellpadding=5 width=$width align=center>
<td align=right colspan=2 valign=top>
<select onchange=\"GoUrl(this)\">
<option> News precedenti--->:
<option> ";
while ($r2 = mysql_fetch_array($result2)) {
extract($r2);
echo "<option value=index.php?month=$month><strong class=black-small> -> $month </strong>";
}
echo "</select> </td>
</tr></table></form> ";
mysql_free_result($result2);
}
mysql_close();
?>
and finally this is part of the addnews.php code
MYSQL_CONNECT($hostname,$username,$passwrd) OR DIE("Couldnt connect to the database, sorry mate!");
@mysql_select_db($dbName) or die( "Unable to select database");
$month = gmdate("F(Y)");
$query = "INSERT into $maintable values (NULL,'$thedate','$month','$nome','$topic','$entry')";
$result = mysql_query($query);
header ("Location: ../index.php"); //the header function redirects the page to the index one. you can change this if you wish.
// echo "<font color=red>".mysql_error()."</font>"; //get rid of the beginning slashes if you get errors, this will tell you why.
mysql_close;
}
BASICALLY I ONLY NEED TO CHANGE THE DATE FORMAT !!!!
Hope you can help me !!!
Ciao
Roberto