激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频

JavaScript日期時(shí)間格式化函數

時(shí)間:2024-08-29 22:03:25 JavaScript 我要投稿
  • 相關(guān)推薦

JavaScript日期時(shí)間格式化函數

  函數代碼:

JavaScript日期時(shí)間格式化函數

  復制代碼 代碼如下:

  Date.prototype.format = function(format){

  var o = {

  "M+" : this.getMonth()+1, //month

  "d+" : this.getDate(), //day

  "h+" : this.getHours(), //hour

  "m+" : this.getMinutes(), //minute

  "s+" : this.getSeconds(), //second

  "q+" : Math.floor((this.getMonth()+3)/3), //quarter

  "S" : this.getMilliseconds() //millisecond

  }

  if(/(y+)/.test(format)) format=format.replace(RegExp.$1,

  (this.getFullYear()+"").substr(4 - RegExp.$1.length));

  for(var k in o)if(new RegExp("("+ k +")").test(format))

  format = format.replace(RegExp.$1,

  RegExp.$1.length==1 ? o[k] :

  ("00"+ o[k]).substr((""+ o[k]).length));

  return format;

  }

  調用示例:

  復制代碼 代碼如下:

  setInterval(function(){

  var time = new Date().format("hh:mm:ss");

  var date = new Date().format("yyyy-MM-dd");

  document.getElementById("Time").innerHTML=time;

  document.getElementById("Date").innerHTML=date;

  },1000);

【JavaScript日期時(shí)間格式化函數】相關(guān)文章:

淺析jQuery 遍歷函數javascript03-29

Javascript函數的定義和用法分析03-31

JavaScript中push(),join() 函數實(shí)例詳解03-31

最常用的20個(gè)javascript方法函數03-10

英語(yǔ)日期時(shí)間的表達03-06

JavaScript中常見(jiàn)的字符串操作函數及用法07-24

Excel日期與時(shí)間設置教程03-03

JavaScript基于正則表達式數字判斷函數03-31

有關(guān)javascript實(shí)現的多個(gè)層切換效果通用函數示例03-31

激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频