<%@page import ="java.util.*,java.text.*"%>
<%
SimpleDateFormat template= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now= template.format(new java.util.Date());
%>
//时间格式是随便你调的 如果你只要20101208
<%
SimpleDateFormat template= new SimpleDateFormat("yyyyMMdd HH:mm:ss");
String today = template.format(new java.util.Date()).substring(0,8);
%>
页面可以这么写
后台处理时可以转换成java.Sql.Date类型存到数据库中 。
在页面上直接用 new Date()就行了,可以尝试一下。
<%@page
import
="java.util.*,java.text.*"%>
<%
SimpleDateFormat
template=
new
SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");
String
now=
template.format(new
java.util.Date());
%>
type="hidden"
name="date"
value="<%=now%>"/>
//时间格式是随便你调的
如果你只要20101208
<%
SimpleDateFormat
template=
new
SimpleDateFormat("yyyyMMdd
HH:mm:ss");
String
today
=
template.format(new
java.util.Date()).substring(0,8);
%>
type="hidden"
name="date"
value="<%=today
%>"/>