Announcement

Collapse
No announcement yet.

Displaying dates correctly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying dates correctly

    Hi

    I have this code:

    PHP Code:
    $cid1 mysql_result($result$i"today");
     
    $cid2 mysql_result($result$i"time"); 
     
    //Convert unix timestamp to date
     
    $cid2 date("H:i:s"$time); 
    $cid1 is displaying the date correctly as 2005-03-28
    $cid2 should be displaying the time. The time is being inserted in the database correctly yet it keeps displaying as 19:00 no matter what. Each record in the database is differant yet it keeps showing 19:00.

    Anyone see something I am doing wrong? Maybe there is a better way to insert the time in the database.

    Here is the code that I am using to insert time and date into the database.

    PHP Code:
    $newcomment $_POST['newcomment'];
    $member $_POST['mid'];
    $ip $_SERVER['REMOTE_ADDR'];
    $now time();
    $today date("Y-m-d");
    sqlquery("INSERT INTO $comments_table VALUES('', '$newcomment', '$member', '$username', '$ip','$now','$today')"); 
    Remember, I am very new to learning PHP/MYSQL!




    Thanks!

    http://www.icecreamforum.com

  • #2
    you can use
    PHP Code:
    $now TIMENOW
    to get the Unix timestamp from when the page started loading (init.php called). Date/times are usually stored as Unix timestamps in databases.

    You can use the vbdate() functions to format a readable date again.

    The reason you always get 19:00 as a time is that you only store the date and not the time in your example.
    Want to take your board beyond the standard vBulletin features?
    Visit the official Member to Member support site for vBulletin Modifications: www.vbulletin.org

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X