JavaScript page dynamic display time change sample code

Source: Internet
Author: User
Tags current time datetime getdate local time

  Page Dynamic display time changes in a number of ways, this article for you to use JavaScript specific implementation, interested friends do not miss

The code is as follows: <html>  <head>  <title></title>    <script>  function Getdatedemo () { /*   //Declaration time   var date = new Date ();  alert (date);/Current time   alert ( Date.tolocalestring ())//Convert to local time   alert (date.getfullyear ());//Show Year   alert (Date.getmonth () + 1);//Show Month 0-11, you need to add 1  alert (Date.getdate ()),//display January date   alert (Date.getday ()),//show the date of the week, Weeks   alert ( Date.gethours ())//Get hour time   alert (date.getminutes ());//get Current minute   alert (date.getseconds ());//get current number of seconds   Alert (Date.getmilliseconds ());//Get the current number of milliseconds   alert (date.gettime ());//Get the millisecond value from 0 o'clock midnight, January 1, 1970, to the current time   */  Get year, month, day, hour, minute, second   var mydate = new Date ();  var years = Mydate.getfullyear ();  var month = Mydate.getmonth ( + 1;  var date = mydate.getdate ();  var hours = mydate.gethours ();  var minutes = mydate.getminutes (); &nb Sp var seconds = mydate.getseconds ();   //month display as two digits as September   if (Month < 10 ) {  month = "0" + month; }  if (date <) {  date = "0" + date; }   //Time stitching   var dateTime = year + "years" + month + "Month" + Date + "Day" + Hours + "time" + minutes + "min" + seconds + "SEC";   //docume Nt.write (dateTime)//print current time     var divnode = document.getElementById ("Time");  divnode.innerhtml = datetime;   }  window.setinterval ("Getdatedemo ()", 1000);//Every 1 seconds, call Getdatedemo ()   </script >  </head>  <body>  <div id= "Time" ></div>  </body>  </ html> 
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.