js获取今天是一年中的第几天


// 获取今天是一年中的第几天
getDay() {
  const currentYear = new Date().getFullYear().toString();
  // 今天减今年的第一天(xxxx年01月01日)
  const hasTimestamp = new Date() - new Date(currentYear);
  // 86400000 = 24 * 60 * 60 * 1000
  let hasDays = Math.ceil(hasTimestamp / 86400000);return hasDays;
},

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM