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

94
Views
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
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!