1.
<script> window.onload=function () {getdateandtime (); SetInterval (getdateandtime,1000); }//Gets the date and time of the system and displays it on an element function Getdateandtime () {var mydate = new Date (); var year = Mydate.getfullyear (); var month = Mydate.getmonth () +1; var day = Mydate.getdate (); var week = Mydate.getday ();//day of the Week Formateweekday (week);//Format Day of the week var hour = mydate.gethours (); var minute = Mydate.getminutes (); var second = Mydate.getseconds (); var str = formatenum (year) + ' Years ' +formatenum (month) + ' month ' +formatenum (day) + ' days ' +formatenum (hour) + ' +formatenum (minute) + ' Min ' +formatenum (second) + ' s '; DOCUMENT.BODY.INNERHTML=STR; var showTime =document.getelementbyid ("P"); SHOWTIME.INNERHTML=STR; }//Format day of the week function Formateweekday (num) {if (num===0) return ' Sunday '; if (num===1) return ' Monday '; if (num===2) return ' Tuesday '; if (num===3) return ' Wednesday '; if (num===4) return ' Thursday '; if (num===5) return ' Friday '; if (num===6) return ' Saturday '; }//format a digit preceded by a 0 function formatenum (num) {return num<10? ' 0 ' +num:num; } </script>2.
<style> img{width:100px height:100px} </style> <script> window.onload=function () {getdateandtime (); SetInterval (getdateandtime,1000); }//Gets the date and time of the system and displays it on an element function Getdateandtime () {var mydate = new Date (); var p = document.getElementById (' P '); var hour = mydate.gethours (); var minute = Mydate.getminutes (); var second = Mydate.getseconds (); var str = Formatenum (hour) + ":" +formatenum (minute) + ":" +formatenum (second); p.innerhtml = ' Current time is ' +str; var imgs =document.getelementsbytagname (' img '); for (var i =0;i
2016-06-02 gets the current date and time of the system and displays it on an element