Page real-time update time of JS instance code

Source: Internet
Author: User
Tags current time getdate

  This article mainly introduces the page real-time update time of the JS instance code, the need for friends can refer to the

  Code as follows: function StartTime () {                     var today = new Date (); Define date Objects                         var yyyy = Today.getfull Year (); Via Date Object getFullYear () method returns the year                          var MM = Today.getmonth () + 1; Via Date Object GetMonth () method returns the year                          var DD = Today.getdate (); Via Date Object GetDate () method returns the year                           VA R hh = today.gethours (); Via Date Object Gethours method return hours                         var mm = Today.getminutes (); Getminutes by Date object return min                         var SS = Today.getseconds (); GE with date objectsTseconds method Return sec                         //If the value of minutes or hours is less than 10, the The value plus 0, for example, if the time is 3:20 P.M. 9 seconds, then show 15:20:09                        &N Bsp MM = Checktime (mm);                      DD = Checktime (DD);                      MM = checktime (mm);                      SS = checktime (ss);                      var day; Used to Save Week (Getday () method get week number)                      if (Today.getday () = 0 Day = "Sunday"                      if (today.getday () = 1) da y = "Monday"                      if (today.getday () = 2) Day = "Tuesday"                      if (today.getday () = 3) Day = "Wednesday "                     if (today.getday () = 4) Day =" Thursday "                     if (today.getday () = 5) Day = "Friday"                      if (today.getday () = 6) Day = "Saturday"       & nbsp              document.getelementbyid (' Nowdatetimespan '). InnerHTML = yyyy + "-" + MM + " -"+ dd +" "+ hh +": "+ mm +": "+ SS +  " + day;                      settimeout (' StartTime () ', 1000); Reload StartTime () method                   &NBSP in every second            function checktime (i) {                     if (I <) {                         i = "0" + i;                                   &N Bsp        return i;                 &NBSP,       Call: <strong> Current time: </STRONG&G T <font color= "White" ><span id= "Nowdatetimespan" ></span></font>       
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.