+ 1

how do I print the current day of the week e.g. Monday

when I do this: var d = new Date(); d1 = d.getDay(); document.write(d1); I get the day of the week in number form( using zero notation with sunday = 0).

19th Jun 2016, 11:14 AM
Victor Ogudu
Victor Ogudu - avatar
3 ответов
+ 2
In JS you will get the result by number only. So here take a manual array of days.. it's simple. var d = new Date(); var i = d.getDay(); var days =["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; var daysName = days [i]; document.write(daysName);
19th Jun 2016, 11:55 AM
Lipak Kumar
Lipak Kumar - avatar
0
I know this method of using an array. I was actually looking for an inbuilt JS Date() method. Thanks though.
19th Jun 2016, 12:28 PM
Victor Ogudu
Victor Ogudu - avatar
- 2
No, there is no such way to get this.
20th Jun 2016, 5:39 PM
Lipak Kumar
Lipak Kumar - avatar