c语言中time_t类型是一个长整型,怎样用JavaScript将这个长整型转换为字符串 "YYYY-MM-DD HH:MM:SS "
------解决方案--------------------
<script language=javascript>
Date.prototype.toFormatString=function()
{
var strMonth=(this.getMonth()+parseInt(1)).toString();
strMonth=(strMonth.length==1)?( "0 "+strMonth):strMonth
var strDate=this.getDate().toString();
strDate=(strDate.length==1)?( "0 "+strDate):strDate
var strHour=this.getHours().toString();
strHour=(strHour.length==1)?( "0 "+strHour):strHour
var strMin=this.getMinutes().toString();
strMin=(strMin.length==1)?( "0 "+strMin):strMin
var strSen=this.getSeconds().toString();
strSen=(strSen.length==1)?( "0 "+strSen):strSen
return this.getFullYear()+ "- "+strMonth+ "- "+strDate+ " "+strHour+ ": "+strMin+ ": "+strSen
}
var longTime=1189071000000
var temp=new Date(longTime)
alert(temp.toFormatString())
</script>