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