Announcement

Collapse
No announcement yet.

Real Time Clock

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Real Time Clock

    Here is the code to add a real time clock to the HS 2 header.

    This will work even if you are using the scrolling weather forcast.

    Add this to meta.htm
    PHP Code:
    <script>
    <!--
    function 
    clockTime() {
     var 
    dte = new Date();
     var 
    intYear dte.getYear();
     var 
    intDay dte.getDate();
     var 
    intMonth dte.getMonth() + 1;
     var 
    intHours dte.getHours();
     var 
    intMins dte.getMinutes();
     var 
    intSec dte.getSeconds();
     var 
    strAmPm;
     if (
    12 intHours) {
      
    strAmPm="PM";
      
    intHours-=12;
     } else {
      
    strAmPm="AM";
     }
     if (
    intHours == 0intHours=12;
     if (
    intMins<=9intMins="0"+intMins;
     if (
    intSec<=9intSec="0"+intSec;
     
    clock.innerHTML intMonth+'/'+intDay+'/'+intYear+' '+intHours+':'+intMins+':'+intSec+' '+strAmPm;
    }
    function 
    startClock() {
     
    setInterval("clockTime()",1000);
    }
    //-->
    </script
    This is similiar to the other clock script posted but note that it writes to clock.innerHTML and not userclock.

    Then go to Setup, WebSite and find Functions To Call with Body Onload.
    Add this to the text box.
    PHP Code:
    startClock() 
    If you are doing both the clock and weather then make sure you seperate the function calls by a ;

    PHP Code:
    displayWeather();startClock() 
    --
    Jeff Farmer
    HS 3, HSPhone
    My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
    Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

    Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2
Working...
X