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?