Q:

Javascript change content based on server time

I'm working on a site for a company who's phone lines are only open certain hours of the day. So I'm trying to write a script that says if it's between the hours of 8 AM and 8 PM Eastern time, then show the phone number, if not, show a button leading to the contact form. I can't figure out how to get the clock so it runs off of the server time, and won't change if a user changes their computer clock.

A:

Since you are talking about server time here, I would assume you have access to the back end language. If this is the case you could do something like this
<?php
    $h = date("H");
    if ( $h >= 8 && $h <= 20 ) {
        echo '<a href="1800 555 123" rel="tel">Call us</a>';
    } else {
        echo '<a href="/contact">Contact page</a>';
    }
?>

This will display a link to a phone number, during your hours of 8-8, otherwise, it will display a link to your contact page

