Add days to the date on the site

Add days to the date on the site

Html

<div class="day"></div>
<div class="month"></div>

Ordinary divas, where we will write the meaning.

Js

const day = document.querySelector('.date');
const month = document.querySelector('.month');
let d = new Date();

d.setDate(d.getDate() + 1);
day.textContent = d.getDate();

let month = 2;
let arr = [
'января',
'февраля',
'марта',
'апреля',
'мая',
'июня',
'июля',
'августа',
'сентября',
'ноября',
'декабря',
];
month.textContent = arr[month + 1];

Strictly speaking, into a variable d we drive the current day and display it in any div with a class date… Then we create an array of months in the genitive case and work with them. d.getDate() + 1, where 1 is the number of days by which we increase the current date. Everything is pretty simple and versatile. Use)

Leave a Reply

Your email address will not be published. Required fields are marked *