JS implementation of small clock, JS in the use of date objects?

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.