Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda