Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Javascript: get calendarweek from date

20.04.2022 (πŸ‘3530)

Javascript: get calendarweek from date

 

//*get current calendarweek in the year

 var calendarweek = dt.calendarweek();

 

or

//*get current calendarweek in the year

var calendarweek = new Date().calendarweek();

 

 

 

Ein Bild, das Tisch enthΓ€lt.

Automatisch generierte Beschreibung

 

 

This javascript code extends a date variable by the calendarweek function

    Date.prototype.calendarweek = function () {

        //------< Date.prototype.calendarweek() >--------

        //*extends a date variable by a calendarweek() property

 

        var currentdate = this;     //current extend date-variable

        var january_01 = new Date(currentdate.getFullYear(), 0, 1);

 

        //*calendar days already passed

        var calendardays = Math.floor((currentdate - january_01) / (24 * 60 * 60 * 1000));

 

        //*week by 7days

        var calendarweek = Math.ceil((currentdate.getDay() + 1 + calendardays) / 7);

 

        //return current calendarweek

        return calendarweek;

 

        //------</ Date.prototype.calendarweek() >--------

    };