当前位置:网站首页>js根据当天获取前几天的日期
js根据当天获取前几天的日期
2022-08-11 06:14:00 【Crazy_GirlLL】
js根据当前获取n天前的日期 并封装成为 YYYY-MM-DD格式
export function getAgoDay(n){
let date= new Date();
let seperator = "-"
let newDate = new Date(date.getTime() - n*24*60*60*1000);
let year = newDate.getFullYear();
let month = newDate.getMonth()+1;
let day = newDate.getDate();
return year.toString() + seperator + month.toString() + seperator + day.toString()
}使用方法
// 获取七天前的日期 数字传递几就是获取几天前
console.log(getAgoDay(7));边栏推荐
- Implement general-purpose, high-performance sorting and quicksort optimizations
- Edge 提供了标签分组功能
- Implementation of FIR filter based on FPGA (5) - FPGA code implementation of parallel structure FIR filter
- 实现通用的、高性能排序和快排优化
- 博途PLC 1200/1500PLC ModbusTcp通信梯形图优化汇总(多服务器多从站轮询)
- Internet phone software or consolidation of attack must be "free" calls security clearance
- MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段
- Attitude solution - gyroscope + Euler method
- Daily SQL - find each of the students school gpa minimum (window)
- 1688 product interface
猜你喜欢

抖音获取douyin分享口令url API 返回值说明

unable to extend table xxx by 1024 in tablespace xxxx

《Generative Adversarial Networks》

Daily sql-seek the sum of successful investments in 2016

Trill keyword search goods - API

图的拉普拉斯矩阵

实现通用的、高性能排序和快排优化

强烈推荐一款好用的API接口

Implementation of FIR filter based on FPGA (5) - FPGA code implementation of parallel structure FIR filter

Discourse 的关闭主题(Close Topic )和重新开放主题
随机推荐
淘宝商品详情API接口
每日sql -用户两天留存率
ROS 服务通信理论模型
联想集团:2022/23财年第一季度业绩
JD.com product details API call example explanation
每日sql--统计员工近三个月的总薪水(不包括最新一个月)
C语言每日一练——Day02:求最小公倍数(3种方法)
每日sql -查询至少有5名下属的经理和选举
Taobao sku API interface (PHP example)
概念名词解释
软件测试主要做什么工作,难不难?
2022-08-09 第四小组 修身课 学习笔记(every day)
Cobbleland 博览会 基础系列 1
Daily sql: request for friend application pass rate
MySQL 版本升级心得
Attitude solution - gyroscope + Euler method
A used in the study of EEG ultra scanning analysis process
Douyin API interface
SQL滑动窗口
MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段