getDay() code showing wrong day Javascript

datetime, getdate, javascript

Solution

Change your array to `['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat']`.

(Sunday is the first day in the week if Javascript has a say in it ;)

var currentDate = new Date();

var weekday = ['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat'];

var day = weekday[currentDate.getDay()];

console.log(day);

Problem

This is my first time (yep JS newbie) using `new Date()` and `getDay()` functions in Javascript. The current date given is correct, yet it gives me the day as Friday even thought it shows the day as Thursday if I get current date. I did do a check of previous questions on here but couldn't see any that really explained it. It gives the same result in both Chrome and Firefox. I also checked that my computer is set to the correct time zone, UK GMT. Code: ``` var currentDate = new Date(); console.log(currentDate); var weekday = ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun']; var day = weekday[currentDate.getDay()]; console.log(day); ``` Time and day show in Console: "Thu May 11 2017 22:25:15 GMT+0100 (BST) Fri"

Original source