Date conversion
Posted: Tue Oct 10, 2006 7:48 pm
Yeah, I've searched everywhere and tried everything, but can't get this figured out. This is almost the last part of my project. Below is my code. All I need is to convert the mySQL date timestamp into other date formats. Right now it will display something like 2006-10-25. I need it to show up either as 10-25-2006 or October 25, 2006. Either way it doesn't matter but I'm pulling my hair out getting this part done. Below is my code. I'm only concerned about the date part, everything else works fine.
Code: Select all
<?php
// include needed files
require('../../db_config.php');
require('../../global.php');
require("../../lib/Pager.class.php");
// connect to the database
db_connect($mysql['username'],$mysql['password'],$mysql['database'],$mysql['host']);
// assign config options from database to an array
$config = get_config($mysql['prefix']);
debug_mode($config['debug_mode']);
// remove users that have not verified their email after 72 hours if email verification is enabled
if($config['verify_email']=='true' && $config['prune_inactive_users']=='true'){
PruneInactiveUsers($mysql['prefix']);
}
// make sure user is logged in
require('../auth.inc.php');
////////////////
// start class
$p = new Pager;
// results per page
$limit = 10;
// Find the start depending on $_GET['page'] (declared if it's null)
$start = $p->findStart($limit);
//////////////////////
$sql= 'SELECT * FROM '.$mysql['prefix'].'users WHERE username="'.$_SESSION['username'].'"';
if(!$result = mysql_query($sql))
{
die('The following MySQL query failed. User data could not be retrieved. '.$sql);
}
// assign the user info to variables
while (($row = mysql_fetch_array($result)) != false)
{
$userid = $row['id'];
}
//////enter the user's ID
if($userid != 1)
{
header('Location: ../../support/');
exit;
}
/////////////////
// date time code goes here?
///////////////
{
// list all users
$sql = 'SELECT * FROM `'.$mysql['prefix'].'results` WHERE `user_id`='.$userid.' ORDER BY date';
$sql2 = $sql.' LIMIT '.$start.', '.$limit;
}
if ($result = mysql_query($sql2))
{
if (@mysql_num_rows($result) > 0)
{
$filelist = '';
while (($row = mysql_fetch_array($result)) != false)
{
$filelist .= '<tr class="style1"><td align="left"><b>'.str_chop($row['filename'],25).'</b></td><td align="left">'.$row['date'].'</td><td align="left"><a href="'.$row['folder'].'/'.$row['file'].'.html">View Results</a></td><td align="left"><a href="'.$row['folder'].'/'.$row['file'].'.xls">Download Excel</a></td><td align="left"><a href="'.$row['folder'].'/'.$row['file'].'.zip">Download Zip</a></td></tr>'."\n";
}
}
else
{
if (empty($_GET['search']))
{
$filelist = '<tr><td colspan="4"><span class="style11">There are currently no results.</span></td></tr>';
}
else
{
$filelist = '<tr><td colspan="4"><span class="style11">Your search returned 0 results.</span></td></tr>';
}
}
}
else
{
die('The MySQL query failed. MySQL said: '.mysql_error());
}
$count = mysql_num_rows(mysql_query($sql));
$pages = $p->findPages($count, $limit);
// get the page list
$pagelist = $p->pageList($_GET['page'], $pages);
?>