SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Displaying timestamp error... please help

    Hi,

    can some one tell me what's wrong n this code? it supposed to display the timestamp, on the database it is displaying properly but i guess i have error on my code or is it the Mysql version on the server or PHP, i really cant figure it out since when i uploaded the file on a lower version of MySql and PHP it worked properly, meaning it displayed well, but when i upgraded to Mysql 4.1.12 & PHP 4.3.2 its having problem... the displaying of timestamp became distorted, am not really sure though whether it is the above mentioned issue it could be on my display code as well so i need your opinion guys... thanks in advance.

    It should display like this (05/25/05 18:47 ) but it is displaying this (0/5-/05 25: 1 )

    heres the code i have:


    PHP Code:
    $query "SELECT t_id, e_description, ";
      
    $query .= "e_timestamp, e_duration, s_user, e_status, e_assignedto ";
      
    $query .= "FROM  events ";
      
    $query .= "WHERE t_id='$t_id' ORDER BY e_timestamp;";
      
    $mysqlresult query($query);
      while (
    $row mysql_fetch_row($mysqlresult)) {
        print 
    "<TR bgcolor=#eeeeee>\n";
        print 
    "  <TD class=defaultfont>\n";
        
    $date_var=$row[2];
        
    $YY "$date_var[2]$date_var[3]";
        
    $MM "$date_var[4]$date_var[5]";
        
    $DD "$date_var[6]$date_var[7]";
        
    $hh "$date_var[8]$date_var[9]";
        
    $mm "$date_var[10]$date_var[11]";
        print 
    "$MM/$DD/$YY &nbsp;&nbsp;&nbsp; $hh:$mm\n";
        print 
    "  </TD>\n";
        print 
    "  <TD class=defaultfont>\n";
        
    $thisevent stripslashes($row[1]);
        print 
    "$thisevent\n";
        print 
    "  </TD>\n";
        print 
    "  <TD class=defaultfont>\n";
        print 
    "    $row[3]\n";
        print 
    "  </TD>\n";
        print 
    "  <TD class=defaultfont>\n";
        print 
    "    $row[6]\n";
        print 
    "  </TD>\n";
        print 
    "</TR>\n";
      } 

  2. #2
    SitePoint Addict phpster's Avatar
    Join Date
    Feb 2005
    Location
    Toronto, Canada
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it a unix timestamp or a mysql timestamp? For mysql timestamp you can use the code below

    instead of
    PHP Code:
        $date_var=$row[2];
        
    $YY "$date_var[2]$date_var[3]";
        
    $MM "$date_var[4]$date_var[5]";
        
    $DD "$date_var[6]$date_var[7]";
        
    $hh "$date_var[8]$date_var[9]";
        
    $mm "$date_var[10]$date_var[11]";
        print 
    "$MM/$DD/$YY &nbsp;&nbsp;&nbsp; $hh:$mm\n"
    try this

    PHP Code:
    $date_var=$row[2];
    echo 
    date("m/d/Y H:i",strtotime($date_var)); 
    phpster

    I wish my computer would do what I want it to.
    Not what I tell it to do...

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks zealot! ....so much!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •