码迷,mamicode.com
首页 > 其他好文 > 详细

201506101252_《想要得到时间戳可以用这个编码》

时间:2015-06-10 14:01:07      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:

例如要得到:20150610125348,可以这么做:

  1. function CurentTime()
    {
    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 ss = now.getSeconds();           //秒

    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 + ":";

    if (ss < 10) clock += ‘0‘;
    clock += ss;
    return(clock);
    };

alert(+new Date(CurentTime()));  

 

201506101252_《想要得到时间戳可以用这个编码》

标签:

原文地址:http://www.cnblogs.com/beesky520/p/4565783.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!