伊人怎会持宠而骄
希望有人懂你的低头不语、小心翼翼守护你的孩子气
自定义日期时间格式 
function dateToString(now){
      var year = now.getFullYear();
      var month =toTwo(  now.getMonth()+1 );
      var d =toTwo(  now.getDate() );
      var h = toTwo( now.getHours() ) ;
      var m = toTwo( now.getMinutes() );
      var s = toTwo( now.getSeconds() );
      return year+"-"+month+"-"+d + " " + h + ":" + m + ":" +s;
}
function toTwo( str ){
      return str<10 ? "0"+str : str;
}
 
将字符串转成日期时间格式
function stringToDate( str ){
      return new Date( str );
}
 
时间差函数
function diff(start,end){
      return (end.getTime()-start.getTime())/1000;
}
posted on 2019-01-21 10:22  伊人怎会持宠而骄  阅读(131)  评论(0编辑  收藏  举报