日期:2014-05-16  浏览次数:20373 次

javascript时间格式显示为yyyy-MM-dd HH:mm:ss
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function curDateTime(){
var d = new Date(); 
var year = d.getYear(); 
var month = d.getMonth()+1; 
var date = d.getDate(); 
var day = d.getDay(); 
var hours = d.getHours(); 
var minutes = d.getMinutes(); 
var seconds = d.getSeconds(); 
var ms = d.getMilliseconds();   
var curDateTime= year;
if(month>9)
 curDateTime = curDateTime +"-"+month;
else
 curDateTime = curDateTime +"-0"+month;
if(date>9)
 curDateTime = curDateTime +"-"+date;
else
 curDateTime = curDateTime +"-0"+date;
if(hours>9)
 curDateTime = curDateTime +" "+hours;
else
 curDateTime = curDateTime +" 0"+hours;
if(minutes>9)
 curDateTime = curDateTime +":"+minutes;
else
 curDateTime = curDateTime +":0"+minutes;
if(seconds>9)
 curDateTime = curDateTime +":"+seconds;
else
 curDateTime = curDateTime +":0"+seconds;
return curDateTime; 
}
 
alert(curDateTime());
 
//-->
</SCRIPT>
</BODY>
</HTML>

?