简体   繁体   中英

getDay() return different value to different browsers/computers

I have this code to find the value of weekday of 2012-01-24 (which should be Tuesday):

============

var myDay=new Date();

myDay.setUTCFullYear(2012, 0, 24);

document.write(myDay.getDay());

============

However, different browser/computer shows me different value, some gives 1, some gives 2.

Any clue to fix this problem?

Thank you in advance!

For myDay = new Date(); , use myDay.getUTCDay to get one value for each browser and country. The ordinary getDay method returns a locale-specific value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM