其他分享
首页 > 其他分享> > 获取YYYY-MM-DD当前时间function

获取YYYY-MM-DD当前时间function

作者:互联网

function getDate() {
  var myDate = new Date();
  var month = myDate.getMonth() + 1;
  var Day = myDate.getDate();
  var today = "";
  if (month < 10) {
    if (Day < 10) {
      today = myDate.getFullYear() + "-0" + month + "-0" + Day;
    } else {
      today = myDate.getFullYear() + "-0" + month + "-" + Day;
    }
  }
  else {
    if (Day < 10) {
      today = myDate.getFullYear() + "-" + month + "-0" + Day;
    } else {
      today = myDate.getFullYear() + "-" + month + "-" + Day;
    }
  }
  return today
}

 

标签:function,MM,DD,getFullYear,myDate,month,var,Day,today
来源: https://www.cnblogs.com/feng3037/p/11158557.html