A
A
Ar2019-04-25 12:38:28
JavaScript
Ar, 2019-04-25 12:38:28

How to display the day of the week and month given the ordinal number of the day of the year?

Let's say I write 34 and outputs - February 3 day of the week Sun .....
With the help of if else it turns out but the whole lecture)) In theory, it is necessary to do it in cycles, but how?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2019-04-25
@linuxxx

function dateFromDay(year, day){
  const date = new Date(year, 0);
  return new Date(date.setDate(day));
}

dateFromDay(2019, 34); // Sun Feb 03 2019 00:00:00 GMT+0300 (Москва, стандартное время)

P
ParaBellum577, 2019-04-25
@ParaBellum577

https://learn.javascript.ru/datetime Read first about JS date and time to understand what's going on. These are not libraries) Everything has already been done extremely simply, no conditions are needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question