JSP page to add the current time

JSP page to add the current time

First, the time format

1. The introduction of labels

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

2. Time Format

<Fmt: formatDate> tag is used to format the date in different ways.

<jsp:useBean id="date" class="java.util.Date" />
当前时间:          
<fmt:formatDate value="${date}" type="both" dateStyle="long" pattern="yyyy-MM-dd HH:mm:ss" />
二、动态时间

Js 1. A method of, in a dynamic page displays the current system time 

 a. js added to the <head> <head> intermediate  

 <head>

  <script type="text/javascript">
 function gettime(){
  var d = new Date();
   document.getElementById("time").innerHTML=d;
   window.setTimeout("gettime()",1000);
}
  window.οnlοad=gettime;
 </script>                   

<head>  

b. In the following body plus a div

  <body>    
current time <div ID = 'Time'> </ div>       
    </ body>

Guess you like

Origin www.cnblogs.com/sitian2050/p/11515549.html