Home > Net >  How to convert a date format in JavaScript?
How to convert a date format in JavaScript?

Time:05-25

How to convert the date format '23 MAY 2022' into 25/05/2022 in javascript?

CodePudding user response:

I personally use momentjs

momentjs format syntax

for your case: moment('23 MAY 2022').format("DD/MM/YYYY")

CodePudding user response:

check this out it might help: https://stackoverflow.com/a/60858473/17757846

const newDate = new Date("23 MAY 2022").toLocaleDateString("en-GB", {
  year: "numeric",
  month: "2-digit",
  day: "2-digit",
});;

  • Related