0

i'm attempting to compare the current date to an object array. like below. i need the current date value to show in the format: "February 20, 2020" below is my code.

    let rightNow = new Date();


const dd = rightNow.getDate();
const mm = rightNow.getMonth()+1;
const year = rightNow.getFullYear();
let rightNowActual = dd + '' + mm + '' + year;
console.log(rightNowActual);

i need to compare rightNowActual to the object dates below

const events2020v2 = [

    {event:"EventName1", Dates:'March 07, 2020'},
    {event:"EventName2", Dates:'March 29, 2020'},
    {event:"EventName3", Dates:'May 02, 2020'},
    {event:"EventName4", Dates:'May 31, 2020'},
    {event:"EventName5", Dates:'June 07, 2020'},
    {event:"EventName6", Dates:'February 20, 2020'},

    ];

this is so i can write an if statement when there is a match. like

if(rightNowActual = [some event date]){do something
} else {do something else }
Eddiejm007
  • 11
  • 2
  • [Date.prototype.toLocaleDateString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString) – chriskirknielsen Feb 21 '20 at 22:03
  • The title says you want it in `MM/DD/YYYY` format, but the text says you want it in `MMM DD, YYYY`. – Barmar Feb 21 '20 at 22:03

0 Answers0