converting timestamp to human friendly time

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

GlendonPhilipp
New php-forum User
New php-forum User
Posts: 4
Joined: Wed Feb 26, 2014 5:11 am

converting timestamp to human friendly time

Postby GlendonPhilipp » Wed Feb 26, 2014 5:22 am

hello been having a problem on displaying time please see my code dont know what else can do now

Code: Select all

  echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n";
   echo "<tr><td><b>Username</b></td><td><b>Level</b></td><td><b>Email</b></td><td><b>Last Active</b></td></tr>\n";
   
   for($i=0; $i<$num_rows; $i++){
      $timestamp   = mysql_result($result,$i,"timestamp");
      if (!function_exists('convertDateTime')) {
function convertDateTime($timestamp) {
   $dt = new DateTime("@$timestamp");
   return $dt->format('Y-m-d H:i:s');
}

$timestamp = convertDateTime($timestamp);

}
   for($i=0; $i<$num_rows; $i++){
      $uname  = mysql_result($result,$i,"username");
      $ulevel = mysql_result($result,$i,"userlevel");
      $email  = mysql_result($result,$i,"email");
     
    
      echo "<tr><td>$uname</td><td>$ulevel</td><td>$email</td><td>$timestamp</td></tr>\n";
   }}
   echo "</table><br>\n";


but on output is display both the same output but they have different timestamp number in database please see the image but for the timestamp it is like this "1393418259" please help me convert this plsss
Attachments
php.png
please see this output please help me
php.png (5.95 KiB) Viewed 89 times

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron