Answer the question
In order to leave comments, you need to log in
Where can I get an array with data for the days of the week for the datepicker?
I want to make my own datepicker. But where does the data come from? Where to get data type
const days = [
{
year: 2019,
month: 'january',
number: 1,
day: 'monday'
}
]
Answer the question
In order to leave comments, you need to log in
How do you even know that in such a month there are 28 days, in such a 30 or 31?
/** число дней */
function daysInMonth (month, year) {
return new Date(year, month, 0).getDate();
}
/** день недели 1 числа месяца */
function getFirstDayOfMonth (month, year) {
return new Date(year, month, 1).toLocaleString('ru', { weekday: 'long' });
// если просто номер
// return new Date(year, month, 1).getDay();
}
Days of the week are standard, days in months too. A reference point is taken and any date is calculated.
Day of the week: remainder of the division by 7 of the total number of days.
28 or 29 - by the remainder of dividing by 4 the difference between the years of high and required.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question