博客
关于我
JS获取当前时间
阅读量:66 次
发布时间:2019-02-26

本文共 404 字,大约阅读时间需要 1 分钟。

            var now = new Date();

            var year = now.getFullYear();       //年

            var month = now.getMonth() + 1;     //月
            var day = now.getDate();            //日

            var hh = now.getHours();            //时

            var mm = now.getMinutes();          //分

            var clock = year + "-";

            if (month < 10)

                clock += "0";

            clock += month + "-";

            if (day < 10)

                clock += "0";

            clock += day + " ";

            if (hh < 10)

                clock += "0";

            clock += hh + ":";

            if (mm < 10) clock += '0';
            clock += mm;

            alert(clock);

转载地址:http://fbmz.baihongyu.com/

你可能感兴趣的文章
MySQL必知必会(组合Where子句,Not和In操作符)
查看>>
MySQL必知必会总结笔记
查看>>
MySQL快速入门
查看>>
MySQL快速入门——库的操作
查看>>
mysql快速复制一张表的内容,并添加新内容到另一张表中
查看>>
mysql快速查询表的结构和注释,字段等信息
查看>>
mysql怎么删除临时表里的数据_MySQL中关于临时表的一些基本使用方法
查看>>
mysql性能优化
查看>>
mysql性能优化学习笔记-存储引擎
查看>>
MySQL性能优化必备25条
查看>>
Mysql性能优化(1):SQL的执行过程
查看>>
Mysql性能优化(2):数据库索引
查看>>
Mysql性能优化(3):分析执行计划
查看>>
Mysql性能优化(4):优化的注意事项
查看>>
Mysql性能优化(5):主从同步原理与实现
查看>>
Mysql性能优化(6):读写分离
查看>>
MySQL性能优化(八)--
查看>>
MySQL性能测试及调优中的死锁处理方法
查看>>
mysql性能测试工具选择 mysql软件测试
查看>>
mysql恢复root密码
查看>>