0

I understand JavaScript getDay() in Date objt returns the number from (0-6) based the locale but as we know different regions has different start of the week, eg: in UAE, week starts from Saturday and in US, its Sunday while Asia/Oceania (except China) its Monday. So lets say if today is Monday (24th), then what are the values getDay() returns on different regions/locale?

UAE ->

US ->

Asia ->

Yans
  • 177
  • 1
  • 1
  • 8
  • 1
    the TIMEZONE is based on locale, but the day that is represented by 0 will always be sunday https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay – Kristian May 24 '21 at 15:10

1 Answers1

2

The return value of getDay() does not change by locale. The relevant spec is very clear about this.

It's not clear where you got the idea that the return value from this function would be locale-dependent. Sunday is always represented as 0, Monday is always represented as 1, and so on.

esqew
  • 42,425
  • 27
  • 92
  • 132
  • thanks for that. Is there any way to get the day of start of the week (based on Locale) in Javascript i.e if browser runs in US it should return Sun, and if its run in UAE it returns Sat? – Yans May 24 '21 at 15:29
  • If that's now your question, that's been asked before on this site and would be closed as a duplicate of [How can I determine if week starts on Monday or Sunday based on locale in pure Javascript?](https://stackoverflow.com/questions/53382465/how-can-i-determine-if-week-starts-on-monday-or-sunday-based-on-locale-in-pure-j) – esqew May 24 '21 at 15:54