mmit

以当前时间为例:

 

 

时间戳转为年月日:

var d=new Date();

var year=d.getFullYear();

var month=formater(d.getMonth()+1);

var date=formater(d.getDate());

var gettime=[year,month,date].join(\'-\');

console.log(\'时间戳转换为年月日:\',gettime);

 

function formater(temp){

  if(temp<10){

    return "0"+temp;

  }else{

    return temp;

  }

}

 

 

年月日转换为时间戳:

var date=new Date();

var timeChuo=date.getTime();

console.log(\'年月日转换为时间戳:\',timeChuo);

分类:

技术点:

相关文章:

  • 2022-01-26
  • 2021-11-30
  • 2021-12-05
  • 2021-12-05
  • 2022-02-16
  • 2021-11-30
  • 2021-06-30
  • 2021-11-22
猜你喜欢
  • 2021-12-05
  • 2021-11-19
  • 2021-12-10
  • 2021-12-05
  • 2022-01-15
  • 2022-02-18
  • 2021-11-28
相关资源
相似解决方案