⊗jsPmTmWG 315 of 504 menu

Getting the day of the week in JavaScript

You can also use the Date object to get the number of the current day of the week. This is done using the getDay method. This method returns numbers from 0 to 6, where week starts on Sunday and this day is numbered 0. Monday is day number 1, Tuesday is day number 2, and so on.

Let's see how the getDay method works with an example. Let's say today is Tuesday. Then the following code will output the number 2:

let date = new Date(); console.log(date.getDay());

Display the number of the current day of the week.

Determine if the current day of the week is a weekend or a workday.

Find out how many days are left until next Sunday.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline