Moment.js how to get week of month? (google calendar style)

后端 未结 12 834
挽巷
挽巷 2020-12-03 13:56

I am using Moment.js and it is great. The problem I have now is that I can\'t figure out how to get the week of the month a certain date is. I can only find \"week of year\"

12条回答
  •  无人及你
    2020-12-03 14:39

    Simple using moment.js

    function week_of_month(date) {
    
            prefixes = [1,2,3,4,5];
    
        return prefixes[0 | moment(date).date() / 7] 
    
    }
    

提交回复
热议问题