How to get this java code to work in html I looked through t
How to get this java code to work in html? I looked through the entire coding and found no mistake, but the clock won\'t show up on the browser.
<script type=\"text/javascript\">
 tday=new Array(\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\");
  tmonth=newArray(\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\");
  function GetClock(){var d=new date();
 var nday=d.getDay(),nmonth=d.getMonth(),nyear=d.getYear();
 if(nyear<1000)nyear+=1900;
 var nhour=d.getDay(),nmin=d.getMinutes(),nsec=d.getSeconds();
 if(nmin<=9)nmin=\"0\"+nmin
 if(nsec<=9)nsec=\"0\"+nsec;
 document.getElementById(\'clockbox\').innerHTML=\"\"+tday[nday]+\", \"+tmonth[nmonth]+\" \"+ndate+\",
 \"+nyear+\" \"+nhour+\":\"+nmin+\":\"+nsec+\";
 }
 window.onload=function(){GetClock();
 setInterval(GetClock,1000);
 }
 </script>
 <div id=\"clockbox\"></div
 >
Solution
There are some errors in the given code. Please find below the modified corrected code. Please see the comments for any explanations :
<script type=\"text/javascript\">
 tday=new Array(\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\");
  tmonth=new Array(\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"); //space is required after new keyword
 function GetClock(){var d=new Date(); //Date class it should be
 var nday=d.getDay(),nmonth=d.getMonth(),nyear=d.getYear();
 if(nyear<1000)nyear+=1900;
 var nhour=d.getDay(), nmin=d.getMinutes(), nsec=d.getSeconds();
 if(nmin<=9)nmin=\"0\"+nmin
 if(nsec<=9)nsec=\"0\"+nsec;
 document.getElementById(\'clockbox\').innerHTML=\"\"+tday[nday]+\", \"+tmonth[nmonth]+\" \"+nday+\" \"+nyear+\" \"+nhour+\":\"+nmin+\":\"+nsec; //ndate is not declared, it should be nday
 }
 window.onload=function(){GetClock();
 setInterval(GetClock,1000);
 }
 </script>
-----------------------------------------------------
SAMPLE OUTPUT:
 Saturday, November 6 2016 6:00:14

