为什么时分秒一直为0
function formatDate(v){
if(v instanceof Date){
var year = v.getFullYear();
var month = v.getMonth()+1;
var day = v.getDate();
var hour = v.getHours();
var min = v.getMinutes();
var seconds = v.getSeconds();
var ms = v.getMilliseconds();
alert(year+"-"+month+"-"+day+" "+hour+":"+min+":"+seconds+"."+ms);
if(ms > 0){
return year+"-"+month+"-"+day+" "+hour+":"+min+":"+seconds+"."+ms;
}
if(hour>0 || min > 0 || seconds > 0){
return year+"-"+month+"-"+day+" "+hour+":"+min+":"+seconds;
}
return year+"-"+month+"-"+day;
}
return "";
}
为什么上面alert显示的时分秒一直为0??????