JS 日期時間毫秒值轉化成時間,並且分鍾顯示2位。


Date.prototype.toLocaleString = function() {

var M= this.getMinutes();//獲取

  M=M>9?M:"0"+M; //如果分鍾小於10,則在前面加0補充為兩位數字
    return this.getFullYear() + "年" + (this.getMonth() + 1) + "月" + this.getDate() + "日 " + this.getHours() + ":" + M  ;
};
var ttime=new Date(dt.activityTime ).toLocaleString().replace(/:\d{1,2}$/,' ');


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM