JS Get current date time display week

Source: Internet
Author: User

JavaScript gets the current datetime at the same time as the day of the week, specific code is as follows:

  1. <html>
  2. <head>
  3. <Meta http-equiv= "content-type" content= "text/html; Charset=utf-8 " />
  4. <script type="Text/javascript" src= "https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/ Jquery.min.js "></script>
  5. <script type="Text/javascript">
  6. function CurrentTime () {
  7. var d=New Date (),str=";
  8. Str+=d.getfullyear () + ' year ';
  9. Str+=d.getmonth () + 1+ ' month ';
  10. Str+=d.getdate () + ' Day ';
  11. Str+=d.gethours () + ' time ';
  12. Str+=d.getminutes () + ' min ';
  13. str+= d.getseconds () + ' second ';
  14. return str;
  15. }
  16. SetInterval (function () {$ (' #time '). HTML (currenttime)},1000);
  17. </Script>
  18. </head>
  19. <body>
  20. <div id="Time"></div>
  21. </body>
  22. </html>

Dynamically display the current datetime on the Web page and show the practice of the week:

function ShowTime () {
var show_day = new Array (' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ', ' Sunday ');
var time = new Date ();
var year = Time.getfullyear ();
var month = Time.getmonth () + 1;
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;
alert (year);
Hour < 10? hour = ' 0 ' + hour:hour;
Minutes < 10? minutes = ' 0 ' + minutes:minutes;
Second < 10? Second = ' 0 ' + second:second;
var now_time = year + ' years ' + month + ' month ' + date + ' Day ' + ' + show_day[day-1] + ' + hour + ': ' + minutes + ': ' + second ;
document.getElementById (' Lishow '). InnerHTML = Now_time;
SetTimeout ("ShowTime ();", 1000);
}
SetInterval ("ShowTime ();", 1000);

JS Get current date time display week

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.