朱杰兵blog

jonhney'blog
posts - 140, comments - 1, trackbacks - 0, articles - 0

js 当前日期转yyyy-MM-DD hh:mm:ss

Posted on 2015-01-10 16:01 朱杰兵 阅读(109) 评论(0)  编辑  收藏
var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();

只有注册用户登录后才能发表评论。


网站导航: