I never realize there is pattern character 'c' there. I test the pattern and also get "Fri". Seems we missed something out to get the result as number. Trying multiple 'cccc' also give "Friday".

I used to face the same problem, but I simply solved it using division and modulus.

Code: Select all

`dow = (getDate(2018,2,10)/ 86400000 + 5) % 7;`

divided by 86400000 miliseconds will give result in days after 1 January 1970. Plus 5 because the starting day at 1 January 1970 is Thursday (index 4 from 0 based on Sunday), but my GMT+0700 deduct 7 hours to be less than 1 January 1970. So Friday, 2 January 1970 will be evaluted to 0 at the modulus 7; it should 5 (from 0 based). That's why I plus 5. Depends on your timezone, you maybe need to +4 instead.