JS Page Live Display time

Source: Internet
Author: User

1. Through GetMonth () to achieve the month, starting from 0 to count, need +1;

2. The acquisition of Sunday by Getday (), starting from 0, 0 for Sunday;

3. Get the date by GETDATE ().

4.setTimeout (time1,1000); 1 seconds

5. Display the <div id= "Inn" ></div> in the Div, using the. innerHTML implementation Assignment;

In the use of <input id= "Inn" type= "text"/> use. value to implement the assignment;

1<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>2<%3String Path =Request.getcontextpath ();4String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";5%>6 7<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >89Ten<base href= "<%=basePath%>" > One      A<title>my JSP ' myjsp.jsp ' starting page</title> -<script type= "Text/javascript" ></script> -   the<style> -#Inn{ - border:1px solid #abcdef; - height:100px; + width:500px; -     } +</style> A at<body> -<div id= "Inn" ></div> -<script language= "JavaScript" > -     functiontime1 () { -         varInn=document.getelementbyid (' Inn '); -  in         varDate =NewDate (); -    to         varmonth = Date.getmonth () +1; +         varYear=date.getfullyear (); -         varday=date.getdate (); the         varWeek =Date.getday (); *         varhour =date.gethours (); $         varMin =date.getminutes ();Panax Notoginseng         varSEC =date.getseconds (); -         varWeek1; the         Switch(week) +         { A              Case0:week1= ' Sunday '; Break; the              Case1:week1= ' Monday '; Break; +              Case2:week1= ' Tuesday '; Break; -              Case3:week1= ' Wednesday '; Break; $              Case4:week1= ' Thursday '; Break; $              Case5:week1= ' Friday '; Break; -              Case6:week1= ' Saturday '; Break; -         } theinn.innerhtml=year+ ' +month+ ' month ' +day+ ' Day ' +week1+ ' time: ' +hour+ ': ' +min+ ': ' +sec; -         varinnn=inn.innerhtml;WuyiSetTimeout (time1,1000); the     } - time1 (); Wu</script> -</body> About

JS Page Live Display 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.