当前位置:编程学习 > 网站相关 >>

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>

补充:网页制作,设计基础
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,