HTML中如何获得系统当前的日期

HTML页中该如何获得系统当前的日期,我做的是JSP页面,在提交数据的时候需要当前日期,最好能获得服务器的时期,而不是本地的

function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();

alert(currentdate);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-02-28
可以用javascript,在html的head里面写如下代码
<script language="javascript">
var now=new Date();
document.write("今天是"+now.year()+"年"+now.month()+"月"+now.day()+“日”);
</script>本回答被网友采纳
第2个回答  2012-02-28
html好像没有这个,只能在javascript中写函数然后调用,php中是这样,不知道jsp中如何写函数!
相似回答