PDA

View Full Version : getting date


Sebastian
12-11-2002, 11:25 PM
greetings.

i am trying to get the date added to this snippet of code. I *believe* file_time table has the date info .. question is how do I fetch it along with the rest of the info? this script pulls the top10 newest files added to my download database, but i also want to get the date using file_time in format: D. M, j, Y .. any help?


<?php

$dbhostname= "blah";
$dbusername= "blah";
$dbpassword= "blah";
$dbdatabase= "blah";
$url= "./files/index.php";
$table ="filedb_files";
$listfiles= 10;

$db = @mysql_connect($dbhostname,$dbusername,$dbpassword );
if (!$db) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! @mysql_select_db($dbdatabase) ) {
echo( "<p>Error locating the file " .
"database at this time.</p >" );
exit();
}
$result = @mysql_query("SELECT file_id, file_name, file_dls FROM $table ORDER BY file_time DESC", $db);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
$files = mysql_num_rows($result);

echo "<b><u><center>Newest Files by Date</center></b></u><br>";
$i=1;
$r=0;
while (($myrow = mysql_fetch_row($result)) And ($i<=$listfiles)){
$r=$r + 1;
$i=$i + 1;
echo "$r - <a href='$url?action=file&id=$myrow[0]''><b>$myrow[1]</b></a> ( Downloaded $myrow[2] times )<br>\n"; }
echo "<br><br>\n";
?>

Sebastian
12-12-2002, 12:28 PM
come on, i know this is a piece of cake for some of you people! :)

NTLDR
12-12-2002, 01:30 PM
Somthing along the lines of:

$datevar=date("D. M, j, Y",$datevar);

or

$datevar=gmdate("D. M, j, Y",$datevar);

I think the second one using gmdate() is the prefered method.

Note $datevar is the variable you have the date stored in.