当前位置:网站首页>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));边栏推荐
猜你喜欢

Pinduoduo api interface application example

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

Amazon Get AMAZON Product Details API Return Value Description

抖音关键词搜索商品-API工具

daily sql - query for managers and elections with at least 5 subordinates

Cobbleland 博览会 基础系列 1

进制转换间的那点事

每日sql-统计各个专业人数(包括专业人数为0的)

STM32CUBEIDE(11)----输出PWM及修改PWM频率与占空比

ROS 话题通信理论模型
随机推荐
Tidb二进制集群搭建
Daily sql-statistics of the number of professionals (including the number of professionals is 0)
第一个C函数:如何实现板级初始化?
从苹果、SpaceX等高科技企业的产品发布会看企业产品战略和敏捷开发的关系
梅科尔工作室——BP神经网络
Production and optimization of Unity game leaderboards
每日sql-统计各个专业人数(包括专业人数为0的)
皮质-皮质网络的多尺度交流
Unity3D learning route?
Pinduoduo API interface
Coordinate system in navigation and positioning
每日sql-员工奖金过滤和回答率排序第一
radix-4 FFT principle and C language code implementation
ssh服务攻防与加固
prometheus学习5altermanager
Unity程序员如何提升自己的能力
联想集团:2022/23财年第一季度业绩
Implement general-purpose, high-performance sorting and quicksort optimizations
When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
Douyin API interface