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

93
Vistas
Fetching charges in Stripe for yesterday and current month date

I'm trying to fetch stripe charges for yesterday and the current month depending on the switch statement. However, I think I've got something off. I don't think I'm constructing my date objects as they need to be. This is in JavaScript:

const getEpochValueForTimeRangeStart = function getEpochValueForTimeRangeStart(range) {
  const now = new Date();
  let returnValue;
  switch(range) {
    case 'ALL':
      returnValue = new Date(0);
      break;
    case 'TODAY':
      returnValue = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
      break;
    case 'YESTERDAY':
      returnValue = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0, 0);
      break;
    case 'MONTH':
      returnValue = new Date(now.getFullYear(), now.getMonth() - 1, 0, 0, 0, 0);
      break;
  }
  return Math.floor(returnValue.getTime() / 1000);
}

The 'ALL' and 'TODAY' ones work as expected, but the other two ('YESTERDAY' and 'MONTH') don't work as expected. What am I doing wrong here?

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