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}$/,' ');
posted @ 2017-04-07 15:46  我叫星星  阅读(4361)  评论(0编辑  收藏  举报