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

280
Views
Time zone getting changed after using endOf('quarter') on moment js

I'm using the followiing approach to get the end of a quarter:

function convertToMomentDates(dates) {
  return dates.map((date) => moment(date).tz("Europe/Rome"));
}

function getEndOfQuarter(dates) {
    const lastDate = dates.pop();
  if (!lastDate || !lastDate.isValid()) return null;
    console.log(lastDate.endOf("quarter").format());
    return lastDate.endOf("quarter").format();
}

const dates = [
  "2018-10-01T01:00:00+01:00",
  "2019-01-01T01:00:00+01:00",
];

const endOfQuarterResult = getEndOfQuarter(convertToMomentDates(dates));

console.log(
  endOfQuarterResult ===
    "2019-03-31T23:59:59+01:00"
);

document.getElementById('result').innerHTML = endOfQuarterResult;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.14/moment-timezone-with-data.min.js"></script>
<div id="result"></div>

I mean I'm using all my dates with +1:00 offset and it gets changed to +2:00 after the endOf function, what would be the correct implementation in order to not change the offset...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

On this case the expected result is ok due accoridng Italy/Rome timezone at the end of march, in this case the end of the last quarter it the offset changes to +2. more infor could be seen on this url: https://www.timeanddate.com/time/zone/italy/rome.

about 4 years ago · Juan Pablo Isaza Report
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!