1

Get YYYY-MM-DD for one week ago (using dayjs)

 2 years ago
source link: https://codepen.io/adrianparr/pen/yLpojGG
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
0 unsaved changes
xxxxxxxxxx

CSS (SCSS)

CSS (SCSS)

xxxxxxxxxx
body {
  background-color: #1C1E21;
  color: #e4e4e4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}
h1 {
  text-align: center;
  font-size: 8vw;
  margin: 0;
}
xxxxxxxxxx
const now = dayjs(new Date())
const dateInThePast = now.subtract(7, 'day')
const dateInThePastFormatted = dateInThePast.format('YYYY-MM-DD') 
console.log(dateInThePastFormatted);
var h = document.createElement('h1');
var t = document.createTextNode(dateInThePastFormatted);
h.appendChild(t);
document.body.appendChild(h);

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK