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

267
Views
How to get the first day of the next month in JavaScript

I need to get the first day of the next Month for a datePicker in dd/mm/yyyy format.

how can i do it?

i have this code :

var now = new Date();
if (now.getMonth() == 11) {
  var current = new Date(now.getFullYear() + 1, 0, 1);
} else {
  var current = new Date(now.getFullYear(), now.getMonth() + 1, 1);
}

console.log(current)

but it's give this :

Sat Jan 01 2022 00:00:00 GMT+0200 

i need it like this 01/01/2022

any help here =)?

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

0

To get the first of next month:

let d = new Date();
d.setMonth(d.getMonth() + 1, 1);

Then to format as dd/mm/yyyy:

d.toLocaleDateString('en-GB');

As a runnable snippet:

let d = new Date();
d.setMonth(d.getMonth() + 1, 1);

console.log(d.toLocaleDateString('en-GB'));

about 4 years ago · Juan Pablo Isaza Report

0

You can use toLocaleDateString

var now = new Date();
var current;
if (now.getMonth() == 11) {
  current = new Date(now.getFullYear() + 1, 0, 1);
} else {
  current = new Date(now.getFullYear(), now.getMonth() + 1, 1);
}

console.log(current.toLocaleDateString());

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!