1
Get YYYY-MM-DD for one week ago (using dayjs)
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.
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);
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK