JSP implementation page Real-time display of the current system time method _jsp programming

Source: Internet
Author: User
JS Code
Copy Code code as follows:

<script language= "JavaScript" >
function realsystime (clock) {
var now=new Date (); Creating a Date Object
var year=now.getfullyear (); Get year
var month=now.getmonth (); Get month
var date=now.getdate (); Get Date
var day=now.getday (); Get Week
var hour=now.gethours (); Get hours
var minu=now.getminutes (); Get minutes
var sec=now.getseconds (); Get seconds
month=month+1;
var arr_week=new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var week=arr_week[day]; Get a week in Chinese
var time=year+ "Year" +month+ "month" +date+ "Day" +week+ "+hour+": "+minu+": "+sec"; Combined system time
Clock.innerhtml=time; Show System time
}
Window.onload=function () {
Window.setinterval ("Realsystime (Clock)", 1000); Get and display system time in real time
}
</script>

To show where to add: id= "Clock" for example: <TD id= "Clock"/>
Related Article

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.