当前位置:网站首页>2022-06-10 work record --js- obtain the date n days after a certain date
2022-06-10 work record --js- obtain the date n days after a certain date
2022-06-24 22:37:00 【Little radish】
JS
- Get to a certain date N Days after
If I have got a date , Then I want to add
7
God :
- Implementation method : Convert the currently obtained date to Time stamp , then add
7*24*3600
, If it ismillisecond ( The time stamp is 13 position )
If you want to3600
Back*1000
, The results obtained are converted into date .【 This method is provided by the company's excellent brother , Like it by hand 】
Conversion between date and timestamp Check out my other blog :https://blog.csdn.net/weixin_48850734/article/details/124668189
Get to a certain date 7
Days after ️
// Convert date format to timestamp
function timeToTimestamp(time) {
return new Date(time).getTime();
}
// Convert timestamps to date format
function timestampToTime(timestamp) {
let d = new Date((timestamp+'').length==10?timestamp*1000:timestamp);// Timestamp 10 Bitwise demand *1000, Timestamp 13 You don't need to take a seat 1000【(timestamp+'') Express : Convert to string 】
let yyyy = d.getFullYear() + '-'; // year
let MM = (d.getMonth() < 10 ? '0'+(d.getMonth()+1) : (d.getMonth())+1) + '-'; // month (js Get the month in date.getMonth() What you get is 0-11, So we need to +1)
let dd = (d.getDate() < 10 ? '0'+d.getDate() : d.getDate()); // Japan
let h = (d.getHours() < 10 ? '0'+d.getHours() : d.getHours()) + ':'; // Hours
let m = (d.getMinutes() < 10 ? '0'+d.getMinutes() : d.getMinutes()) + ':'; // minute
let s = (d.getSeconds() < 10 ? '0'+d.getSeconds() : d.getSeconds()); // second
return yyyy + MM + dd + ' ' + h + m + s;
}
// Convert the currently acquired date into a timestamp
let curr_timestamp = timeToTimestamp('2022-06-22 14:00:00'); // 1655877600000
// obtain 7 Days after
timestampToTime(curr_timestamp+7*24*3600*1000); // '2022-06-29 14:00:00'
边栏推荐
- How to grab the mobile phone bag for analysis? Fiddler artifact may help you!
- ThreadLocal内存泄漏问题
- STP spanning tree protocol Foundation
- Rip protocol of dynamic routing protocol
- Zero code can apply data visualization to enterprise management
- The usage difference between isempty and isblank is so different that so many people can't answer it
- Servlet详解
- 【軟件工程】期末重點
- 04A中断的配置
- Yyds dry goods inventory junit5 learning II: assumptions class
猜你喜欢
软件设计的七大原则
Description of software version selection of kt6368a Bluetooth dual-mode transparent chip
A girl has been making hardware for ten years. 。。
Raspberry pie preliminary use
Embedded development: tips and tricks -- clean jump from boot loader to application code
理想L9,智能座舱新潮流
How to extract dates from web pages?
无心剑汉英双语诗003. 《书海》
[QT] QT event handling
一个女孩子居然做了十年硬件。。。
随机推荐
04A interrupt configuration
JMM 最最最核心的概念:Happens-before 原则
虚拟人的产业发展现状
Power system | IEEE paper submission process
2022-06-10 工作记录--JS-获取到某一日期N天后的日期
seven
img2pdf
短视频商城系统,scroll-view如何自适应页面剩余高度
[personal experiment report]
OSPF basic content
How to compare two or more distributions: a summary of methods from visualization to statistical testing
Main steps of system test
[Software Engineering] key points at the end of the period
Publicity of the second batch of shortlisted enterprises! Annual Top100 smart network supplier selection
Docker 安装 MySQL 8.0,详细步骤
socket done
CSRF and SSRF for web attacks
Certificate photo processing
NIO、BIO、AIO
Industrial development status of virtual human