Zeller's formula to calculate the week today

var dayOfTheWeek = function(day, month, year) {

  if (month == 1) {

    month = 13;

    year--;

    }

    if (month == 2) {

    month = 14;

    year--;

    }

    let week = (day + 2 * month + 3 * Math.floor((month + 1) / 5) + year + Math.floor(year / 4)  -Math.floor(year / 100)  +Math.floor(year / 400) ) % 7;

    return week;

};

tips

 If you do not know or want to be friends of the students can micro-channel contact me: qq981145483 (Note: csdn algo)

Published 57 original articles · won praise 5 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_33807889/article/details/102573967