JavaScript retrieves the current date and time and displays the day of the week at the same time

Source: Internet
Author: User

JavaScript retrieves the current date and time and displays the day of the week at the same time. The Code is as follows:

<Html> 

How to dynamically display the current date and time on the webpage and display the week in a timely manner:

Function showTime () {var show_day = new Array ('monday', 'tuesday', 'wedday', 'thurs', 'Friday', 'satur', '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 );}
Articles you may be interested in
  • How to obtain information about the Year, Zodiac, and constellation of the rule by using the date or timestamp in php
  • Why are there always errors between the programmer's estimated time and the actual project completion time?
  • Php extracts the birthday date from the ID card number and verifies whether it is a minor.
  • PHP retrieves the date list for the first 30 days of the current date
  • PHP obtains the current time and timestamp.
  • Php obtains the start and end timestamps of today, yesterday, last week, and this month.
  • PHP obtains the week of the specified date, the first day of the month and the last day of the month.
  • How does PHP obtain the date list for a period of time?

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.