日期:2014-05-18 浏览次数:20786 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> 时间现实测试 </TITLE> <script type="text/javascript"> function getTime(){ var now= new Date(); var year=now.getYear(); var month=now.getMonth()+1; var day=now.getDate(); var hour=now.getHours(); var minute=now.getMinutes(); var second=now.getSeconds(); return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; } function onLoad(){ var timeStr = getTime(); document.getElementById('time').innerHTML = timeStr; setTimeout(onLoad,1000); } </SCRIPT> </HEAD> <BODY onload="onLoad()"> <center> <div id="time"></div> <center> </BODY> </HTML>
------解决方案--------------------
首先上面的回答都不完整
你是要显示服务器的时间 还是本地系统的时间啊
------解决方案--------------------
Calendar cal=Calendar.getInstance();
int year=cal.get(Calendar.YEAR);
int month=cal.get(Calendar.MONTH)+1;
int day=cal.get(Calendar.DAY_OF_MONTH);
String time="";
time+=year+"-";
time+=month+"-";
time+=day;
直接用Java代码就行了
------解决方案--------------------
用java,或scrip等都可以调用时间日期.