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

117
Views
DateTime remove saturday and sunday

I am creating a todo where the default date should be set to + 3 days but only weekdays. I'm using vue so think a computed of some sort should work?

DateTime.utc().plus({ days: 3 }).toFormat('yyyy-MM-dd HH:mm:ss'),

So how can I exclude Saturday and Sunday here? I've tried googling but haven't been able to find a solution..

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

0

the best solution is to use the package luxon-business-day

but if you don't want to add anything you can :

  • calculate date of next saturday
  • see if you can add expecting number of day
  • if not, add difference to day to add

const dayToAdd = 3;
const DateTime = luxon.DateTime;

var nextSaturday = DateTime.utc().startOf('week').plus({ week: 1 }).minus({days: 2});
var dayDifference = nextSaturday.diff(DateTime.utc(), ["days"]).toObject().days;


var addAfterWeekend = 0;
if (dayDifference < dayToAdd) {
  addAfterWeekend = dayToAdd - dayDifference;
}

var date = DateTime.utc().plus({ days: dayToAdd + addAfterWeekend });

console.log(date.toFormat('yyyy-MM-dd HH:mm:ss'));
<script src="https://cdn.jsdelivr.net/npm/luxon@1.21.1/build/global/luxon.min.js"></script>

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!