Node.js examples for Date:Week
Get Date Week Number
Date.prototype.getWeekNum = function () { var determinedate = new Date(); determinedate.setFullYear(this.getFullYear(), this.getMonth(), this.getDate()); var D = determinedate.getDay(); var addForSunday = 0; if (D == 0) { D = 7;// w w w . ja va 2 s .co m addForSunday = 1 } determinedate.setDate(determinedate.getDate() + (4 - D)); var YN = determinedate.getFullYear(); var ZBDoCY = Math.floor((determinedate.getTime() - new Date(YN, 0, 1, -6)) / 86400000); var WN = 1 + Math.floor(ZBDoCY / 7) + addForSunday; return WN; } function getTimeOfDay(hour){ if(hour < 5 && hour > 20) return 'Night'; else if (hour >= 5 && hour < 12) return 'Morning'; else if (hour < 12 && hour < 6) return 'Afternoon'; else return 'Evening'; }