npm.io
1.0.9 • Published 6 years ago

getmonths

Licence
ISC
Version
1.0.9
Deps
0
Size
3 kB
Vulns
0
Weekly
0

Using this package you can get all the months between two dates.

Example

startYear in YYYY format like 2018

endYear in YYYY format like 2018

startMonth in M format like 5

endMonth in M format like 8

monthArray like ["01","02","03","04","05","06","07","08","09","10","11","12"] or ["1","2","3","4","5","6","7","8","9","10","11","12"] or ["JAN","FEB"...] or ["January"...] or ["Jan"...]

Output will be : [05-2018, 06-2018, 07-2018, 08-2018] for first monthArray.

How to use in your code

  { 
      try {
          const startYear = 2018;
          const endYear = 2018;
          const startMonth = 2;
          const endMonth = 9;
          const monthArray = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
          console.log(test.getMonths(startYear, endYear, startMonth, endMonth, monthArray));
      } catch (error) {
          console.log(error);
      }
  }

abhishek2kr

Keywords