js获取某天日期

获取某天日期

getSomeDay(someDay) {
   
	let currentDate = new Date();
	let targetday_milliseconds = currentDate.getTime() + 1000 * 60 * 60 * 24 * someDay;
	currentDate.setTime(targetday_milliseconds);

	const doHandleMonth = (month) => {
   
		let m = month;
		if (month.toString().length == 1) {
   
			m = `0${
     month}`
		}
		return m
	}

	let year = currentDate.getFullYear();
	let month = currentDate.getMonth();
	let date = currentDate.getDate();
	let day = currentDate.getDay();
	let time = parseInt(currentDate.getTime() / 1000);
	month = doHandleMonth(month + 1);
	date = doHandleMonth(date);

	const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
	return {
   
		't': time,
		'y': year,
		'm': month,
		'd': date,
		'w': week[day]
	};
}

相关推荐

  1. js获取天日

    2024-01-01 21:48:02       35 阅读
  2. 数据处理生产环境_获取当前日期的前一天日

    2024-01-01 21:48:02       37 阅读
  3. Springboot获取实时天气

    2024-01-01 21:48:02       14 阅读
  4. js获取光标坐标

    2024-01-01 21:48:02       36 阅读
  5. js获取当前时间

    2024-01-01 21:48:02       38 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-01 21:48:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-01 21:48:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-01 21:48:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-01 21:48:02       20 阅读

热门阅读

  1. 国内低代码平台介绍及优势盘点

    2024-01-01 21:48:02       33 阅读
  2. 微服务(8)

    2024-01-01 21:48:02       34 阅读
  3. Golang标准库sync的使用

    2024-01-01 21:48:02       35 阅读
  4. 源码解析:mybatis调用链之获取sqlSession

    2024-01-01 21:48:02       34 阅读
  5. 浅析 Dockerfile 构建缓存:原理与优化方法

    2024-01-01 21:48:02       39 阅读
  6. python弹奏《起风了》

    2024-01-01 21:48:02       38 阅读
  7. 我自己的Mac装机软件推荐!

    2024-01-01 21:48:02       33 阅读
  8. 网络安全领域八大国际认证

    2024-01-01 21:48:02       30 阅读
  9. MySQL第七章:MySQL的基本函数

    2024-01-01 21:48:02       47 阅读
  10. CSS中背景设置——渐变色和放射渐变

    2024-01-01 21:48:02       29 阅读
  11. (C)一些题15

    2024-01-01 21:48:02       29 阅读
  12. springboot中使用mongodb进行简单的查询

    2024-01-01 21:48:02       40 阅读
  13. CMEMS数据下载

    2024-01-01 21:48:02       35 阅读