js方法,将时间戳转换为yyyymmddhhmmss格式

小鱼儿 2022-06-06 05:16 1269阅读 0赞
  1. var unixTimestamp = new Date( 1477386005*1000 ) ;//获取时间戳
  2. commonTime = unixTimestamp.toLocaleString();//转换为yyyymmddhhmmss格式
  3. //具体实现方法
  4. Date.prototype.toLocaleString = function() {
  5. return this.getFullYear() + "年" + (this.getMonth() + 1) + "月" + this.getDate() + "日 " + this.getHours() + "点" + this.getMinutes() + "分" + this.getSeconds() + "秒";
  6. };

发表评论

表情:
评论列表 (有 0 条评论,1269人围观)

还没有评论,来说两句吧...

相关阅读