I have an API path where I need to have dates where the month is displayed as 2 digits. However, it keeps removing the zero to the left.
For example, when I get the date, if it's Jan through Sept, it only returns 1 digit. So I used the following code to add the extra zero:
const date = new Date();
  const year = date.getFullYear();
  let month = date.getMonth();
  let path = ``;
  switch (month) {
    case (month < 10):
      month = `0${month}`;
      path = `/v2/reports/time/team?from=${year}0${month}01&to=${year}0${month}31`;
      break;
    default:
      path = `/v2/reports/time/team?from=${year}${month}01&to=${year}${month}31`;
      break;
  }
However, when the code actually runs, the path is always printing as so(which returns an error, because the zeros in front of the month in the date are removed):
/v2/reports/time/team?from=2021701&to=2021731
Should be this instead:
/v2/reports/time/team?from=20210701&to=20210731
What am I missing?
 
     
    