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>
时间: 2024-10-25 19:33:06