Introduce the use of the Date object in JS
Dateobj = new Date ()
Dateobj = new Date (dateValue)
Dateobj = new Date (Year,month,date[,hours[,minutes[,seconds[,ms]]);
Here is a sample sample
<script type= "Text/javascript" >function settime () {//Get today's time var now = new Date (); var year = Now.getfullyear (); var month = Now.getmonth (); month + +; var date = Now.getdate (); var day = Now.getday (); var hours = now.gethours (); var minute = Now.getminutes (); var second = Now.getseconds () var arr_week = new Array ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"), var week = arr_week[ Day]; var time = year + "years" + month + "Month" + Date + "Day" + Week + "+ Hours +": "+minute +": "+ second;var Clock = document.g Etelementbyid ("clock"); clock.innerhtml = "Current time:" +time;} Once the download is complete, update the time every second window.onload = function () {Window.setinterval ("settime ()", +);} </script>
Display effect:
JS implementation of small clock, JS in the use of date objects?