The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I have problem with timing

Discussion in 'General Discussion' started by SilverBoy, Oct 11, 2007.

  1. SilverBoy

    SilverBoy Member

    Joined:
    Oct 7, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    this is my first post here.

    I have a web serever managed by hosting company not by me, I told my hosts to change the time of the server to GMT+2, and they say every thing is done, and they give me what they see in the server and it was right, but when I checked the time using some scripts I find it not correct, It's appear like GMT+3, I enterd the cpanel and from the latest vistiors status I find the time is correct, what is wrong with me exactly? is it some thing like DST issue? because I dont want the time to be changed because here we don't use DST, and we need correct time for some processes.

    tip: I think my host changeing the time from WHM.

    thanks in advance.
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    In your script, how are you checking the time? Posting the relevant script contents would help.
     
  3. SilverBoy

    SilverBoy Member

    Joined:
    Oct 7, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    this is the code script (one of scripts as examoles)

    PHP:
    <script type="text/javascript">

    // Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
    // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
    // This notice must stay intact for use.

    //Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
    //Default is that SSI method is uncommented, and PHP is commented:

    //var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' //SSI method of getting server date
    var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method of getting server date

    ///////////Stop editting here/////////////////////////////////

    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
    var serverdate=new Date(currenttime)

    function padlength(what){
    var output=(what.toString().length==1)? "0"+what : what
    return output
    }

    function displaytime(){
    serverdate.setSeconds(serverdate.getSeconds()+1)
    var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
    var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
    document.getElementById("servertime").innerHTML=datestring+" "+timestring
    }

    window.onload=function(){
    setInterval("displaytime()", 1000)
    }

    </script>

    <p><b>Current Server Time:</b> <span id="servertime"></span></p>

    <p style="font: normal 11px Arial">This free script provided by<br />
    <a href="http://www.javascriptkit.com">JavaScript Kit</a></p>
    thanks in advance.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
  5. SilverBoy

    SilverBoy Member

    Joined:
    Oct 7, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    thanks cPanelDavidG for help,

    but in my case, if I didn't declare default time zone, I think it must have no effect on the output, is it right?

    for another example, I have a vBulletin forum, I set the time zone to GMT+2 but the statistics of the forum export in GMT+3, and in this case we defined time zone !!
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    It depends on how various software wishes to use the server's set time zone. For logs, it would make sense that log activity match server time but the actual software displays time in GMT+2 time zone.
     
  7. SilverBoy

    SilverBoy Member

    Joined:
    Oct 7, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    then, do you have any suggest for this issue?
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Given the relatively unpredictable nature of PHP settings in a shared hosting environment, I'd recommend explicitly setting the timezone.
     
  9. SilverBoy

    SilverBoy Member

    Joined:
    Oct 7, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    in every script? or in WHM?

    I have some scripts in that server and all of them have the same issue.
     
  10. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Note that cPanel/WHM only can set the server settings. PHP may use these settings by default however they may become overwritten by other function calls by other users on the system as PHP is not specifically designed from the ground up to isolate ALL settings set by different users.

    Hence my previous recommendation that explicitly declaring timezones before performing any timezone-dependent calculation would be a good PHP coding convention to embrace.
     
    #10 cPanelDavidG, Oct 11, 2007
    Last edited: Oct 11, 2007
Loading...

Share This Page