当前位置:网站首页>Calculation date or date formatting
Calculation date or date formatting
2022-07-25 17:31:00 【Your beauty fascinates me】
// Calculate the date
const calculationDate = val => {
const dd = new Date()
dd.setDate(dd.getDate() - val)
return `${
dd.getFullYear()}-${
(dd.getMonth() + 1) < 10 ? `0${
dd.getMonth() + 1}` : (dd.getMonth() + 1)}-${
dd.getDate() < 10 ? `0${
dd.getDate()}` : dd.getDate()} ${
dd.getHours() < 10 ? `0${
dd.getHours()}` : dd.getHours()}:${
dd.getMinutes() < 10 ? `0${
dd.getMinutes()}` : dd.getMinutes()}:${
dd.getSeconds() < 10 ? `0${
dd.getSeconds()}` : dd.getSeconds()}`
}
// Date formatting
const formatData = value => {
const dd = new Date(value)
return `${
dd.getFullYear()}-${
(dd.getMonth() + 1) < 10 ? `0${
dd.getMonth() + 1}` : (dd.getMonth() + 1)}-${
dd.getDate() < 10 ? `0${
dd.getDate()}` : dd.getDate()} ${
dd.getHours() < 10 ? `0${
dd.getHours()}` : dd.getHours()}:${
dd.getMinutes() < 10 ? `0${
dd.getMinutes()}` : dd.getMinutes()}:${
dd.getSeconds() < 10 ? `0${
dd.getSeconds()}` : dd.getSeconds()}`
}
example :
const da = new Date()
da.setHours(da.getHours() - 1)
console.log(formatData(da), calculationDate(0), ' Shu Du Fu ')
effect :
边栏推荐
- 02. Add two numbers
- Postdoctoral recruitment | West Lake University Machine Intelligence Laboratory recruitment postdoctoral / Assistant Researcher / scientific research assistant
- What is metauniverse gamefi chain game system development? Development and application case and analysis of gamefi metauniverse NFT chain game system
- 一篇文章了解超声波加湿器
- 走马卒
- 2022年最新北京建筑施工焊工(建筑特种作业)模拟题库及答案解析
- An article about ultrasonic humidifier
- How to prevent the unburned gas when the city gas safety is alarmed again?
- 动态规划题目记录
- STM32 PAJ7620U2手势识别模块(IIC通信)程序源码详解
猜你喜欢

Outlook 教程,如何在 Outlook 中搜索日历项?
![[Hardware Engineer] can't select components?](/img/bd/fdf62b85c082f7e51bf44737f1f787.png)
[Hardware Engineer] can't select components?
![[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part3): rule-based problem classification](/img/4c/aeebbc9698f8d5c23ed6473c9aca34.png)
[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part3): rule-based problem classification

Jenkins' file parameters can be used to upload files

吴恩达机器学习编程作业无法暂停pause问题解决

I'm also drunk. Eureka delayed registration and this pit!

博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理

「数字安全」警惕 NFT的七大骗局

Hcip notes 11 days

Postdoctoral recruitment | West Lake University Machine Intelligence Laboratory recruitment postdoctoral / Assistant Researcher / scientific research assistant
随机推荐
【PHP伪协议】源码读取、文件读写、任意php命令执行
论文阅读_多任务学习_MMoE
[cadence Allegro PCB design] error: possible pin type conflict gnd/vcc power connected to output
Hcip notes 12 days
博后招募 | 西湖大学机器智能实验室招聘博士后/助理研究员/科研助理
Chapter III data types and variables
Google Earth engine - download the globalmlbuildingfootprints vector collection of global buildings
11、照相机与透镜
Product life cycle to be considered in making intelligent hardware
Customize MVC project login registration and tree menu
I2C communication - sequence diagram
03.无重复字符的最长子串
咨询下flink sql-client怎么处理DDL后,fink sql里面映射表加字段以及JOb?
Outlook 教程,如何在 Outlook 中搜索日历项?
Go language series: where does go come from and where will go?
[solution] the Microsoft edge browser has the problem of "unable to access this page"
Is it safe to open a futures account online? How to apply for a low handling fee?
Pymongo saves data in dataframe format (insert_one, insert_many, multi-threaded saving)
【硬件工程师】元器件选型都不会?
The gas is exhausted! After 23 years of operation, the former "largest e-commerce website in China" has become yellow...