Results 1 to 6 of 6

Thread: Date() Function Behaving strange... -[RESOLVEDish]-

Threaded View

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Resolved Date() Function Behaving strange... -[RESOLVEDish]-

    In my login file I have this code to add an entry to my login table.
    PHP Code:
    // Create an entry to the login table...
    $query "INSERT INTO `login` (`user_id`, `staff`, `guid`, `lastactive`) ";
    $query.= "VALUES (".$UserID.", 'no', '".$UserGUID."', '".date("Y-m-d H:i:s" ,time())."')";
    $results mysql_query($query); 
    When it is run and I see what the date/time was in the database I get:
    2000-11-00 44:68:93

    So I then Added in theses lines just after the above:
    PHP Code:
    $Date date("Y-m-d H:i:s" ,time());
    echo 
    "date(\"Y-m-d H:i:s\" ,time()) = $Date"
    The output and data in database was:
    2004-11-14 07:41:41

    So I then removed these two debug lines and the next time the entry to the database was:
    2000-11-00 44:70:74


    I can't understand how those two lines could possibly affect the SQL that is done before it .


    Update: I have tested this a few times since posting this and its the echo statement, if I take it out its the wrong time if I put it in its the right time, but I get errors later on cos I still have header info to send.
    Last edited by Electroman; Nov 14th, 2004 at 11:31 AM.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

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



Click Here to Expand Forum to Full Width