Javascript Clock - Line break -
this current code i'm using clock (from tutorial), , i'm wondering if there way make time appear above date?
function rendertime(){ // date var mydate = new date(); var year = mydate.getyear(); if(year < 1000){ year +=1900; } var day = mydate.getday(); var month = mydate.getmonth(); var daym = mydate.getdate(); var dayarray = new array("sunday","monday","tuesday","wednesday","thursday","friday","saturday"); var montharray = new array("january","february","march","april","may","june","july","august","september","october","november","december"); // date end // time var currenttime = new date(); var h = currenttime.gethours(); var m = currenttime.getminutes(); var s = currenttime.getseconds(); if( h == 24){ h = 0; } else if(h > 12){ h = h - 0; } // adding 0 infront of single digit values if(h < 10){ h = "0" + h; } if(m < 10){ m = "0" + m; } if(s < 10){ s = "0" + s; } var myclock = document.getelementbyid("clockdisplay"); myclock.textcontent = "" +dayarray[day]+ " " +montharray[month] + " " +daym+ " " +h+ ":" +m+ ":" +s; myclock.innertext = "" +dayarray[day]+ " " +montharray[month] + " " +daym+ " " +h+ ":" +m+ ":" +s; settimeout("rendertime()", 1000); // time end } rendertime();
i'm not sure .textcontent , .innertext myself - i'm beginner. html:
<!doctype html> <html> <head> <title></title> <link rel="stylesheet" href="css/style.css" /> <script type="text/javascript" src="js/scripts.js"></script> </head> <body onload="rendertime()"> <div id="clockdisplay" class="container"></div> </body> <html>
css:
.container { font-family: verdana; font-weight: normal; color: #000000; text-align: right; font-size: 20px; }