Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

See the Server Time?

Discussion in 'Workarounds and Optimization' started by Please enter the name, Dec 25, 2017.

Tags:
  1. Please enter the name

    Joined:
    Feb 10, 2017
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    LOWW
    cPanel Access Level:
    Website Owner
    Hi
    My Hoster use:
    cPanel Version 68.0 (build 19)

    How its possible to see the current Time? I installed with the Robot on my Hosting CPanel Stuff an AdServer who should deliver outside of the youth protected time the other ads.
    Here my Demo Page: - Removed -
    The huge problem the show the Demo contend on the wrong time. So I want see which Time on my Server run but could not find any information.
    Thanks!
     
    #1 Please enter the name, Dec 25, 2017
    Last edited by a moderator: Dec 25, 2017
  2. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    824
    Likes Received:
    299
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    To see the time on the server, you could use a simple PHP call
    PHP:
    <?php
    echo "The time is " date("h:i:sa");
    ?>
    • h - 12-hour format of an hour with leading zeros (01 to 12)
    • i - Minutes with leading zeros (00 to 59)
    • s - Seconds with leading zeros (00 to 59)
    • a - Lowercase Ante meridiem and Post meridiem (am or pm)
    Note that the PHP date() function will return the current date/time of the server!

    If you are trying to serve time sensitive adds, you will really need the time on the computer of the person that is calling the page - here is a Javascript that might get you started
    Code:
    <script type="text/javascript">
       function godate() {
      var daystuff = new Date();
      var weekday = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
      var monthname=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
      c_weekday = weekday[daystuff.getDay()] + " ";
      c_month = monthname[daystuff.getMonth()] + " ";
      c_day = daystuff.getDate() + " ";
      c_year = daystuff.getFullYear() + " ";
      c_hour = daystuff.getHours();
      c_minute = daystuff.getMinutes();
      c_second = daystuff.getSeconds();
      if (c_hour >= 12) {
       c_part = " pm";
      } else {
       c_part = " am";
      }
      if (c_hour > 12) {
       c_hour -= 12;
      }
      if (c_hour == 0) {
       c_hour = 12;
      }
      if (c_minute < 10) {
       c_minute = "0" + c_minute;
      }
      if (c_second < 10) {
       c_second = "0" + c_second;
      }
      document.getElementById("raw").firstChild.nodeValue = c_weekday + c_day + c_month + c_year + c_hour + ":" + c_minute + ":" + c_second + c_part;
      setTimeout('godate ();', 1000);
       }
    </script>
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,878
    Likes Received:
    89
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,

    As far as I know if you use PHP codes to get the information, the timezone will be as per what is set in the PHP application that your host has provided to you, but not sure if the exact server time will be displayed in it or not. Create a phpinfo in your account and check what timezone your PHP application is configured with.. However, if you want to know the server time, then you may have to contact your host once to cross reference it with the PHP timezone..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    rpvw likes this.
  4. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    824
    Likes Received:
    299
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    24x7server is correct

    To see what timezone your PHP has set, you could use a code like
    PHP:
    <?php
    echo date_default_timezone_get();
    ?>
    However, the time and timezone on the server is somewhat irrelevant if you are serving advertisements that must follow a watershed time for age suitability.

    Unless your advertisements can only be seen from one place (eg from a public wi-fi zone - and if this were the case I have to wonder why you would be using a public facing hosting service), you need to know the time on the end users computer, not your server, to be able to decide to serve a particular advertisement or not.

    The only way I know to do this is by using JavaScript to interrogate the end users computer time (and hope they have it correctly set), and then you can eg set a cookie, and read that back into your PHP code to decide what adds to serve.

    This is full of complications involving page refreshes and possibly hidden frames, and is inherently unreliable, as it is completely dependant on the end user browser settings ......... well no one said it was going to be easy :eek:

    The safe way of serving age suitable adds, is to know the end users age via some sign-up/sign-in with proof of age process - if you can get that to work securely and properly, with no possibility of spoofing the users age, and without falling foul of data protection laws, you will make a fortune since no one has actually achieved it yet !

    Whilst I personally find all of this intensely interesting, it really has nothing to do with cPanel, and you may get better help from a more suitable forum like Stack Overflow - Where Developers Learn, Share, & Build Careers
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #4 rpvw, Dec 26, 2017
    Last edited: Dec 26, 2017
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    The previous posts should help. Let us know if you have any additional questions.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Please enter the name

    Joined:
    Feb 10, 2017
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    LOWW
    cPanel Access Level:
    Website Owner
    thx I dont see that someone replay to my tread. normally i should get an E-Mail?!
    The time is correct on the Webserver...
    - Removed -
    The Script look interesting but I dont care about the Time on the local Device. I just care about the right in my Country who say between X - Y Hours I can show quite everything.
    I will make sure where the problem start and why "Bad" Add would appear when the should not be there. So see if the Time right or not is my first step.

    In my Test scenario I use the Revive Add Server who should show the add just between a certain time. The Youth Protection think (I know i have miss spelled it) is just a demo to see if it work or not and now I see the dont work. Its hard to talk about the "Ads" Theme with someone because nobody want share there "secrets" or whatever.

    Beside of the thinks we could not solve by our own could there any reason or wrong setting why the Revive get an Wrong time? I dont know wrong Time Zone somewhere in the system?
     
    #6 Please enter the name, Dec 27, 2017
    Last edited by a moderator: Dec 27, 2017
  7. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,462
    Likes Received:
    418
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You'll need to subscribe to the thread to get notifications for it. When replying, click the "More Options" button, bottom right corner of reply box. On that page is an option to "Watch this thread and receive email notifications"

    You can also go here:
    https://forums.cpanel.net/account/preferences
    And set the " Automatically watch threads that you create or when you reply..." bit to get alerts on all threads you take part in.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    If the test PHP script shows the correct time, then it suggests the issue is with the specific script you are using. You may want to check with the support team of the script you are using to see if there are any hard-coded or configurable options related to the time zone that you can adjust.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Please enter the name

    Joined:
    Feb 10, 2017
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    LOWW
    cPanel Access Level:
    Website Owner
    I use the Revive Add Server this is a "Standalone" Installation like Joomla, PHPBbb Forum,... and other stuff you might know.
    So when I know that the Time on the Server is correct the Revive Add Server do something weired.
    THX to everyone here.
     
  10. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    824
    Likes Received:
    299
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #10 rpvw, Dec 27, 2017
    Last edited by a moderator: Jan 4, 2018
  11. Please enter the name

    Joined:
    Feb 10, 2017
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    LOWW
    cPanel Access Level:
    Website Owner
    The installation run without any problems.
    I will try it next week. The Server would show no Adult Content! The local time is 10:38!
    There run something very wrong.
     
  12. Please enter the name

    Joined:
    Feb 10, 2017
    Messages:
    22
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    LOWW
    cPanel Access Level:
    Website Owner
    I will use that:
    Time Delivery Rules - Revive Adserve
    documentation.revive-adserver.com/display/DOCS/Time+Delivery+Rules
     
    #12 Please enter the name, Jan 4, 2018
    Last edited by a moderator: Jan 4, 2018
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice