en.javascript.info/1-js/4-data-structures/11-datetime/2-get-week-day/solution.md
2015-01-11 01:54:57 +03:00

16 lines
516 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Метод `getDay()` позволяет получить номер дня недели, начиная с воскресенья.
Запишем имена дней недели в массив, чтобы можно было их достать по номеру:
```js
//+ run
function getWeekDay(date) {
var days = ['вс','пн','вт','ср','чт','пт','сб'] ;
return days[ date.getDay() ];
}
var date = new Date(2014,0,3); // 3 января 2014
alert( getWeekDay(date) ); // 'пт'
```