score:0

Accepted answer
const programs = [
    { video: "URL1", startDate: 1644492517146, endDate: 1644492517446 },
    { video: "URL2", startDate: 1644492517726, endDate: 1644492517646 },
    { video: "URL3", startDate: 1644492507746, endDate: 1644492517546 },
    { video: "URL4", startDate: 1644492517746, endDate: 16474492519746 }
];

const now =new Date().getTime(); // gives similar to 1644492517146

const currentProgram = programs.filter(
  p => new Date(p.startDate) < now && new Date(p.endDate) > now
);

console.log(currentProgram) // gives [{ video: "URL4", startDate: 1644492517746, endDate: 16474492519746 }]

score:0

function compareDates(startDate,endDate){
  let current=new Date();
  return startDate>=current && endDate<=current;
}

score:0

export const checkTime = (startDate, endDate) => {// startDate= 1644405993, endDate = 1644406032
const now = new Date()
const bookingStartDate = new Date(startDate) // use this step to convert your date if its stored in a different format
const bookingEndDate = new Date(endDate) // use this step to convert your date if its stored in a different format
return now.getTime() > bookingStartDate.getTime() && now.getTime() < bookingEndDate.getTime()

Related Query

More Query from same tag