I’m trying to hide open-house listings on my map that have already occurred. The only date information I have looks like this:
Public: Sat Sep 18, 10:00AM-2:00PM
I need to be able to compare this date with today so I can create an if statement to hide expired open-houses.
Using this code I was able to cut off the beginning text:
const str = 'Public: Thu Feb 11, 10:00AM-2:00PM';
const opdate = (str.substr(8));
console.log(opdate); // Displays "Thu Feb 11, 10:00AM-2:00PM"
This is where I am now stuck...I can not figure out how to convert this to another format to be able to compare it to today's date. It is missing the year which I'm sure is going to cause issues towards the end of every year, and it has an end time which really isn't necessary as I just need to compare the actual date to today's date.