0

Suppose i have a string like ,

let oldDate = "30-1-2022";
let presentDate = new Date(Date.now()).toLocaleDateString("en-GB");
console.log(oldDate,presentDate)

Now my question is how can i check wich Date is the biggest Date.

mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • The statements you have written are invalid JS or at least not doing what you expect: oldDate will contain -1993 for example because no quotes and you have two `= =` signs where you only want one – mplungjan Feb 01 '22 at 07:44
  • I fixed your string and made you a [mcve] – mplungjan Feb 01 '22 at 07:50
  • `const gtToday = date => { const [oDD, oMM, oYYYY] = date.split("-"); const now = new Date(); now.setHours(15, 0, 0, 0); return new Date(oYYYY, oMM - 1, oDD, 15, 0, 0, 0) > now;}` – mplungjan Feb 01 '22 at 07:58

0 Answers0