日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

獲取當(dāng)前的日期 格式為YYYY-MM-dd 和時(shí)間戳轉(zhuǎn)時(shí)間

作者:熱忱學(xué)習(xí) 更新時(shí)間: 2022-01-18 編程語(yǔ)言
獲取當(dāng)前的日期 格式為YYYY-MM-dd

getNowFormatDate () {

var date = new Date();

var seperator1 = "-";

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;

// console.log(currentdate)

return currentdate;

}
    //時(shí)間戳轉(zhuǎn)時(shí)間
    timestampToTime: function timestampToTime (timestamp) {
      var time = new Date(parseInt(timestamp) * 1000);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return y + '.' + m + '.' + d + ' ' + h + ':' + mm + ':' + s;
    },

?

原文鏈接:https://blog.csdn.net/qq_42180156/article/details/91448364

欄目分類
最近更新