Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda