+ 5

How to make a First and last day of the Year ?

var fullDate=new Date(); var Days=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; var y=fullDate.getFullYear(); var m=fullDate.getMonth(); var first_day=new Date(y,m,1).getDay(); var TotDays=fullDate.getDate(); var StartDay=Days[first_day]; document.write("Start Day:"+StartDay+"<br>"); NumberOfDays=new Date(y,m+1,0).getDate(); var last=new Date(y,m,NumberOfDays).getDay(); document.write("End Day:"+Days[last]+"<br>");

6th Aug 2022, 3:41 AM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
3 Antworten
6th Aug 2022, 3:57 AM
SoloProg
SoloProg - avatar
+ 5
var date = new Date(); var first=new Date(date.getFullYear(), 0, 1).toLocaleString("default", { weekday: "long" }); var last=new Date(date.getFullYear(), 11, 31).toLocaleString("default", { weekday: "long" });
6th Aug 2022, 4:05 AM
Steve
Steve - avatar
+ 1
#include <iostream> using namespace std; int leapcheck(int yr){ if(yr%400==0) return 1; else if(yr%100==0) return 0; else if(yr%4==0) return 1; else return 0; } int main() { int diff,year,nlp,d,val,d0=1,lp=0; cin >> year; diff=year-1; // taking year 1 as base case for(int i=1;i<year;i++) if(leapcheck(i)==1) lp++; nlp=diff-lp; d=1+1*(nlp)+2*(lp); // d=d0+1*nlp+2*lp; val=d%7; switch(val){ case 1 : cout << "1st day of the year " << year << " was Monday" << endl; break; case 2 : cout << "1st day of the year " << year << " was Tuesday" << endl; break; case 3 : cout << "1st day of the year " << year << " was Wednesday" << endl; break; case 4 : cout << "1st day of the year " << year << " was Thursday" << endl; break; case 5 : cout << "1st day of the year " << year << " was Friday" << endl;
7th Aug 2022, 7:43 AM
Harsh Nama
Harsh Nama - avatar