js计算时分秒代码
js计算时分秒代码
<script>
function b(n){
return n>=10 ? n : "0"+n;
}
function getNow(){
var d=new Date();
var s = d.getFullYear() + "-" +b((d.getMonth()+1)) + "-" + b(d.getDate()) + " " + b(d.getHours()) + ":" + b(d.getMinutes()) + ":" + b(d.getSeconds());
return s;
}
alert(getNow());
</script>
补充:网页制作,设计基础