Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:37:11+00:00 2026-06-07T08:37:11+00:00

I need a code to get all the days of all weeks in current

  • 0

I need a code to get all the days of all weeks in current month,

a function that accept number on week as parameter and return all the days of that specific week.

the code must be in javascript or jquery,

Can anybody help me out ?

Thanks in advance 🙂

Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:37:14+00:00Added an answer on June 7, 2026 at 8:37 am

    Here is complete solution for getting all week days of the specific week of the current month using java script.

    Follow Steps:

    1) HTML:

    <div class="input">
      <label>
        No. of Weeks..?: 
      </label>
      <input type="text" size="3" id="txtweek" name="txtweek" />
      <input type="button" id="btnok" name="btnok" value="Get Week Days" onclick="getWeekDays();" />
    </div>
    <div id="result">
    </div>
    

    2) CSS:

    .input label{
      font-size:13px;
      font-weight:bold;
    }
    .input input{
      font-size:13px;
      border:1px solid #333;
    }
    .weekdays{
      width:40%;
      background-color:#11a8a5;
      box-shadow: 7px 7px 3px #446689;
      margin-top:5px;
    }
    .weekdays th{
      background-color:#885511;
      border-bottom:1px solid #a4a525;
      color:#ffad25;
    }
    .weekdays td{
      text-align:center;
    }
    

    3) JAVA SCRIPT:

     var startDay = 0; //0=sunday, 1=monday etc.
    var week = 0;
    var result = "";
    
    function weekDaysInMonth(week, startDay) {
    
        if (startDay == "" && startDay == null && typeof(startDay) == "undefined") {
            startDay = 0;
        }
        if (week != "" && week != null && typeof(week) != "undefined") {
    
            var weekDay = new Array(7);
            weekDay[0] = "Sunday";
            weekDay[1] = "Monday";
            weekDay[2] = "Tuesday";
            weekDay[3] = "Wednesday";
            weekDay[4] = "Thursday";
            weekDay[5] = "Friday";
            weekDay[6] = "Saturday";
    
            var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    
            var currDate = new Date();
            var currWeekDay = week * 7;
            var monthLastDay = new Date(currDate.getFullYear(), currDate.getMonth() + 1, 0).getDate();
    
            if (currWeekDay > monthLastDay) {
                currWeekDay = monthLastDay;
                currDate = new Date(currDate.getFullYear(), currDate.getMonth() + 1, 0);
    
            } else {
                currDate = new Date((currDate.getMonth() + 1) + '/' + currWeekDay + '/' + currDate.getFullYear());
            }
    
            var d = currDate.getDay(); //get the current day
            var weekStart = new Date(currDate.valueOf() - (d <= 0 ? 7 - startDay : d - startDay) * 86400000); //rewind to start day
            var weekEnd = new Date(weekStart.valueOf() + 7 * 86400000);
    
            var wkDay = weekStart.getDate(); //Start week Date
            var nextDate = weekStart; //Assign Next Date as Current Week Start Date
            var htmlWeekDays = "",
                nextDay = "";
            while (wkDay != weekEnd.getDate()) {
                nextDay = nextDate.getDay();
                htmlWeekDays += "<tr><td>" + nextDate.getDate() + " " + monthNames[nextDate.getMonth()] + "," + nextDate.getFullYear() + "</td><td>" + weekDay[nextDay] + "</td></tr>";
                nextDate = new Date(nextDate.getTime() + 86400000);
                wkDay = nextDate.getDate();
    
            }
            if (htmlWeekDays != "") {
                htmlWeekDays = "<table cellpedding=0 cellspacing=0 class='weekdays'><tr><th>Date</th><th>Day</th></tr>" + htmlWeekDays + "</table>";
            }
            return htmlWeekDays;
        } else {
            return false;
        }
    
    
        return new Date(year, month, 0).getDate();
    }
    
    function getWeekDays() {
        week = document.getElementById("txtweek").value.trim();
        if (week != "" && !isNaN(week)) {
            result = weekDaysInMonth(week, startDay);
            document.getElementById("result").innerHTML = result;
        }
    }
    

    Above script just accept no of week and get all days of that week with dynamically generated table format.

    I have also generated bins demo on http://codebins.com/bin/4ldqpbi

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get numbers of all days of a week (MON to SUN)
i have this code: def some_method(): #i need to get some attrs :( return
I have an app that I need to get the source code to update
How do you get the current location of iPhone through code? I need to
I have R code that I need to get to A parallelization stage. Im
I need to get the source code of the particular URL using a java
I need to get the maximum value out of this code, but it's really
I need to get items from a html list from the vb.net code behind
I need to get some random colors to draw a pie. My code works
I am writing some code in which i need to get a line from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.