Closed Thread
Results 1 to 5 of 5

Thread: Trouble With Database and PHP Time

  1. #1
    rforum is offline x10Hosting Member rforum is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    8

    Trouble With Database and PHP Time

    I’m having problems with time on my hosting account.

    While I’m checking the session time from a database table, then comparing it to time(), the time is an hour off.

    First I save the time to the database with SET `session_time` = FROM_UNIXTIME(".time()."). (I also tried SET `session_time` = NOW() )
    Later in the same script, I recall the saved value from the database and compare it to time() to check how long the user has been inactive.
    The times are an hour off even though I saved and recalled the time in the same execution of the script! I know the script works because I test it on another sever before putting it on x10.

    I have had the times change on me twice so far. The first time, about a week ago, the time difference was an hour off. It was back to normal when I checked again the next day. The second time started about three hours ago, and is still an hour apart. My sever name is Lotus.x10 and my domain name is rforum.x10hosting.com. Help?

    Part of the function:

    PHP Code:
    $check getuser($iuser); #('SELECT * FROM `user` WHERE `user_id` = \''.$iuser.'\' LIMIT 1';)
    $timelast strtotime($check['session_time']);
    $timenow time();
    echo 
    '<BR>Time diff:'.($timenow $timelast); #(=3600)
     
    if ($timelast != $timenow){
    $query "UPDATE `user` SET `session_time` = FROM_UNIXTIME(".time()."), `session_ip` = '$ipnow' WHERE `user_id` = '$iuser'";


  2. #2
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Trouble With Database and PHP Time

    I just verified the times, they look to be correct...
    Corey Arbogast | CEO
    █ 888-X10-9668 - corey[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

  3. #3
    rforum is offline x10Hosting Member rforum is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    8

    Re: Trouble With Database and PHP Time

    Run this time script on rforum.x10hosting.com.

    PHP:
    PHP Code:
    $dbtime strtotime(mysql_result(mysql_query("SELECT NOW()"),0));
    $phptime time();
    echo 
    "MYSQL time: $dbtime";
    echo 
    "<BR>PHP time: $phptime"
    The result I'm getting is:
    MYSQL time: 1219631462
    PHP time: 1219635062
    Last edited by rforum; 08-24-2008 at 10:31 PM.

  4. #4
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Trouble With Database and PHP Time

    The date.timezone configuration directive for PHP is set to America/New_York, which is EST (or GMT-5).

    The server is set to CDT (or GMT-6), so that is the cause between the differences.

    A possible reason behind the variation over the last few days may have been caused by the inconsistency with the PHP versions configuration files, they've been changed around a lot the last few days.

    I've discussed it with Corey and we're going to be moving all servers' times up to EST. They're all currently in CDT now. This will probably happen sometime within the next few hours.
    Last edited by Bryon; 08-26-2008 at 09:46 PM.

  5. #5
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Trouble With Database and PHP Time

    I just want to let you know I've made the time change on all of our free servers. If you have this issue again, let us know.

Closed Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Replies: 3
    Last Post: 01-02-2008, 04:05 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. search database with php
    By niahossain in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 10-17-2007, 11:06 AM
  5. PHP BB 2.0.16 Manual instalation
    By GFIV in forum Free Hosting
    Replies: 8
    Last Post: 09-14-2005, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers