month javascript get data range

Solutions on MaxInterview for month javascript get data range by the best coders in the world

showing results for - "month javascript get data range"
Eleonora
15 Jan 2016
1$(function(){
2var formatted_date = function(date){
3                var m = ("0"+ (date.getMonth()+1)).slice(-2); // in javascript month start from 0.
4                var d = ("0"+ date.getDate()).slice(-2); // add leading zero 
5                var y = date.getFullYear();
6                return  m +'-'+d+'-'+y; 
7}
8         var curr_date =new Date();
9     
10         var first_day = new Date(curr_date.getFullYear(), curr_date.getMonth(), 1); 
11 
12         var last_day = new Date(curr_date.getFullYear(), curr_date.getMonth() + 1, 0);
13                 
14         var month_start_date =formatted_date(first_day);
15                 
16         var month_end_date =formatted_date(last_day);
17                 
18         date=month_start_date + ' To '+month_end_date; // date range for current month
19 
20        /*
21         var month_end_date =formatted_date(new Date()); // limit current month date range upto current day.
22       */
23 
24 
25});
26    
27