Menu

Current Server Time offset

Help
tthdoc
2009-09-27
2013-05-30
  • tthdoc

    tthdoc - 2009-09-27

    I was checking my logs today and noticed that it showed me logging in 2 hours prior to the current time.  I see when I goto Admin it shows Current Server Time and Current User Time.  It obviously uses current server time in the logs.  But when I look at the logs, I would like to see the time someone logged in relative to my local time.  How can I change this. There was an old message from John about changing the timediff value in session.php, but I tried that on current version (4.2.2) but it did nothing.  How can I change the offset so the logs reflect my local time?

    Thanks,
    Doc

     
  • roland_l

    roland_l - 2009-09-28

    Hello Doc -

    Just offering one opinion before you undertake any great effort to "get synched". In fact, it reminds me of a nightmare a few years ago in the US when the Daylight Savings Time was changed (temporarily) from its long established dates of "switchover". I was still using Win98 computers in the work office. Because M$OFT no longer supported W98, I had to "hack" a hotfix file for Win2K to make it work for my "old" machines. Comparing the two "time" files allowed me to locate the code changes necessary to craft  an "unsupported" fix which worked for a few more years! Please let this be our secret!   BTW - The only part I like is "Fall  Back" anyway.

    Anyway, my observation is that while you may get your Server and User times to synch in PGV for the reasons you desire, this will probably be  just a cosmetic fix. Unless you have full accees to the host server, your other PGV files will still be time-stamped based on when they hit your host. If you intend to be able to fix or "rollback" from any issues, remebering which is which might become frustrating very quick!

    Right now, my Server time is 1 hour later than it really is in my living room. I use it to gauage my work time in PGV. When it gets to be "bedtime", I can wrap up my work for the day and still get an extra hour of sleep for the next work day! - YMMV.

    Hopefully others will chime in with the the real "fix" you desire.

    RL

     
  • tthdoc

    tthdoc - 2009-10-02

    Just checking back if anyone has a solution to this?  As I said, John had posted an answer to this many versions ago, so I am sure it can be done, just not sure where to change something.  Here is the message that John had left (but it was in 2004):

    If you want, you can manually adjust the time difference by editing the session.php file and changing line 383:
    $_SESSION = 0;
    change it to
    $_SESSION = (60*60*5);

    This will add 5 hours to the timediff and adjust the displayed time.

    Thanks,

    Doc

     
  • tthdoc

    tthdoc - 2009-10-02

    Noticed after I posted it did not post the astericks.  It should have  said 60 times 60 times 5 not 60605.  And just to mention again, I tried locating timediff in the current session.php file and changing it but it did not work.

    Thanks again
    Doc

     
  • Greg Roach

    Greg Roach - 2009-10-02

    If you must change this, I would advise keeping the logs recorded in the server time zone, and change printlog.php to convert them back to local time for display.  This may not be easy if you have set the calendar/language to anything other than gregorian/english.

    FYI, at some point in the future, the logs will be stored in the database, making it much easier to apply local-time conversions.

     
  • Mark Hattam

    Mark Hattam - 2009-10-02

    If you want, you can manually adjust the time difference by editing the session.php file and changing line 383:

        $_SESSION = 0;
       
    change it to

        $_SESSION = (60*60*5);

    (the asterixes work fine in the email from the forum, it's only the online forum display that tries to be clever. Much like a wiki or textpattern CMS. The Preview in the forum shows you what the online displayed formatting will be)

     
  • tthdoc

    tthdoc - 2009-10-02

    Fisherbest,

    It sounds like you are saying that when I view the log from administration, it will show my local times, but the actual log will have the server time.  If that is correct, that sounds fine.  Where should I change this?

    dxradio,

    The line 383 reference was from 2004.  I went to the current includes/sessions.php file and found a reference to timediff on line 657 as follows:

    $_SESSION = $LANGUAGE;
    if (!isset($_SESSION)) {
    $_SESSION = 0;
    }

    and changed it to correct the time by 2 hours as follows:

    $_SESSION = $LANGUAGE;
    if (!isset($_SESSION)) {
    $_SESSION = (60* 60 *2);
    }

    and the logs still show the server time, not my local time.

    Doc

     
  • Greg Roach

    Greg Roach - 2009-10-02

    <<Where should I change this?>>

    In my previous post, I said that you should change printlog.php.

    Column 1 has the format "02.10.2009 17:50:33" (ignore my earlier remark about english/gregorian - I thought these dates were stored in localised format).

    Convert this string to a timestamp, add on however many hours, then convert back to a date.

     
  • tthdoc

    tthdoc - 2009-10-03

    Fisharebest,

    Thanks for the help.  I thought I would share what I did if anyone is interested in modifiying the output of the log files.  In my case, I wanted to change the time by 2 hours so when I viewed the logs, i knew when someone logged in relative to my time zone.  While I was at it, I wanted it to be in a more readable format for me, so I changed the date and time from "02.10.2009 17:50:33" to "Fri 10/2/2009 5:50 pm". 

    In printlog.php, after line 68 where it has read the file I put the following:

    for ($chg = 0; $chg < $num ; $chg++) {  //for each item in the array
    $timeonly = explode(' - ', $lines ,3); //separate the array items
    $chgtime = strtotime($timeonly) + (60*60*2); // change the datetime into a unix time string and add 2 hours
    $timeonly = date("D m/d/Y h:i a",$chgtime); //change new unix time back into datetime was d.m.Y H:i:s
    $lines = implode(" - ", $timeonly); //rebuild the array
    }

    Thanks again for the help.

    Doc

     

Log in to post a comment.