当前位置: 代码迷 >> Web前端 >> Date()轹呗のメソッド――14桁日付の获得方法
  详细解决方案

Date()轹呗のメソッド――14桁日付の获得方法

热度:307   发布时间:2012-11-10 10:48:50.0
Date()轹呗のメソッド――14桁日付の取得方法
参照ドキュメント:http://www.w3school.com.cn/js/jsref_obj_date.asp
function getSysTimestamp() {
    var now = new Date();

    var date=now.getDate();
    var month=now.getMonth()+1;
    var year=now.getYear();

    var timestr;
    timestr = year;
    timestr += ((month<10)?"0":"")+month;
    timestr += ((date<10)?"0":"")+date;

    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var milseconds = now.getMilliseconds();
    timestr += ((hours<10)?"0":"")+hours;
    timestr += ((minutes<10)?"0":"")+minutes;
    timestr += ((seconds<10)?"0":"")+seconds;
    timestr += milseconds;
    return timestr;
}
  相关解决方案