Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
How can I get diff using dayjs from date to now type of array?

I want to know how can i get diff using dayjs from date to now type of array?

and i wanna make locale function too.

// if i input 2021-03
// output will be [2021-04, 2021-05, ... 2022-05]
const createdAt = "2021-03";
const selectableMonths = Array(12)
  .fill(0)
  .map((_, index) => {
    const dateText = dayjs().subtract(index, 'months');
    return {
      text: i18next.t("date_format",{
        val: new Date(dateText.format("YYYY-MM")),
        fotmatParams: {
          en: {
            short: {
              year: 'numeric',
              month: 'short',
            },
            long: {
              year: 'numeric',
              month: 'short',
              day: 'numeric',
            },
          },
          ko: {
            short: {
              year: 'numeric',
              month: 'long',
            },
            long: {
              year: 'numeric',
              month: 'long',
              day: 'numeric',
            },
          },
        },
      }
      ),
      value: {
        from: dateText.format('YYYY-MM'),
        to: dateText.add(1,'months').format('YYYY-MM'),
      }
    }
  })
  .filter((v) => dayjs(v.value.from).isSameOrAfter(dayjs(teamCreatedAt)));

this is my code..

how can i get a array like [2021-04, 2021-05, ... 2022-05]

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!