Get the month number from the week number Javascript [closed]

0

Good morning

I am new to javascript I am in the dilemma, with a combobox I return the year concatenated with the week number is a weeks combobox, I am in the problem of getting the number of the month from the number of the week obtained from the value

            <div class="cmb_body_container" style="">
            <div value="201822" class="cmb_item">Semana 22-18</div>
            <div value="201821" class="cmb_item">Semana 21-18</div><div value="201820" class="cmb_item">Semana 20-18</div>
            <div value="201819" class="cmb_item">Semana 19-18</div><div value="201818" class="cmb_item">Semana 18-18</div>
            <div value="201817" class="cmb_item">Semana 17-18</div><div value="201816" class="cmb_item">Semana 16-18</div>
            <div value="201815" class="cmb_item">Semana 15-18</div><div value="201814" class="cmb_item">Semana 14-18</div>
            <div value="201813" class="cmb_item">Semana 13-18</div><div value="201812" class="cmb_item">Semana 12-18</div>
            <div value="201811" class="cmb_item">Semana 11-18</div></div>

Any help is appreciated

    
asked by Mike Mtz 06.06.2018 в 19:03
source

1 answer

1

I came out with this

     function getMonthNumber(w, y) {
        var d = (1 + (w - 1) * 7); // calcula el numero de dias a partir del 1 de enero
         var fecha = new Date(y, 0, d);
         return fecha.getMonth() + 1;
    };
    
answered by 06.06.2018 в 20:07