JS Display current date time and week _javascript tips

Source: Internet
Author: User
Tags getdate

JavaScript gets the current date time and displays the day of the week, with the specific code as follows:

 
 

Dynamically display the current date and time on a Web page and display the week's practice:

function ShowTime () { 
  var show_day=new Array (' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ', ' Sunday '); 
  var time=new Date (); 
  var year=time.getyear (); 
  var month=time.getmonth (); 
  var date=time.getdate (); 
  var day=time.getday (); 
  var hour=time.gethours (); 
  var minutes=time.getminutes (); 
  var second=time.getseconds (); 
  Month<10?month= ' 0 ' +month:month; 
  month=month+1; 
  Hour<10?hour= ' 0 ' +hour:hour; 
  minutes<10?minutes= ' 0 ' +minutes:minutes; 
  Second<10?second= ' 0 ' +second:second; 
  var now_time= ' current time: ' +year+ ' year ' +month+ ' month ' +date+ ' Day ' + ' ' +show_day[day-1]+ ' ' +hour+ ': ' +minutes+ ': ' +second; 
  document.getElementById (' Showtime '). Innerhtml=now_time; 
  SetTimeout ("ShowTime ();", 1000); 

On this aspect of the content of the Internet, there are JS to get the current date and time at the same time, JS to obtain the current time and a week of time and other content, are very valuable reference, I hope that we read more similar articles, will be familiar with similar methods.

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.