您现在的位置是:首页 > 微信小程序

李清波 2019-08-24 微信小程序 1568 复制当前网址

小程序获取当前系统日期和时间


获取当前系统日期

function getNowTime(){
  var now = new Date();
  var year = now.getFullYear();
  var month = now.getMonth() + 1;
  var day = now.getDate();
  if (month < 10) {
    month = '0' + month;
  };
  if (day < 10) {
    day = '0' + day;
  };
  //  如果需要时分秒,就放开
  // var h = now.getHours();
  // var m = now.getMinutes();
  // var s = now.getSeconds();
  var formatDate =  year + '-' + month + '-' + day;
  return formatDate;
}

输出

2019-08-24


文章来源:https://www.liqingbo.com/blog-1598.html

评论