Update Date/Time Button

Discussion in 'Programming' started by selfAfflicted, Aug 8, 2007.

  1. #1
    So I am trying to get an update date/time script to work with the server time, or a given time zone (-5 GMT). Right now, the script below references the local machines time. Thanks for any help on this topic!

    <html>
    <head>
    <script language="jscript" type="">
    function setcompleted()
    {
    var myDate = new Date();

    var str = (myDate.getMonth()+1) + "/" + pad(myDate.getDate()) + "/" + myDate.getFullYear();

    str += " " + pad(myDate.getHours()) + ":" + pad(myDate.getMinutes());

    document.forms[0].date_time.value=str;
    }
    function pad(num)
    {
    if (num &lt; 10)
    return "0" + num;
    else
    return num;
    }
    </script>

    </head>
    <body bgColor="#91a7b8" topmargin="3pt" bottommargin="3pt" leftmargin="3pt" rightmargin="3pt">
    <form>
    <input type="text" value="_currentdatetime" name="date_time" required="false"></input>
    <button language="jscript" onClick="return setcompleted()">Update Date/Time</button>
    </form>
    </body>
    </html>
     
    selfAfflicted, Aug 8, 2007 IP