import React, { useState, useEffect } from 'react';const CountdownTimer = () => { const [timeLeft, setTimeLeft] = useState({ days: 0, hours: 0, minutes: 0, seconds: 0, }); useEffect(() => { const timer = setInterval(() => { const now = new Date(); const nextSunday = new Date(now); nextSunday.setUTCDate(now.getUTCDate() + (7 - now.getUTCDay()) % 7); nextSunday.setUTCHours(19, 0, 0, 0); // Noon PST is 19:00 UTC if (now > nextSunday) { nextSunday.setUTCDate(nextSunday.getUTCDate() + 7); } const difference = nextSunday.getTime() - now.getTime(); const days = Math.floor(difference / (1000 * 60 * 60 * 24)); const hours = Math.floor((difference / (1000 * 60 * 60)) % 24); const minutes = Math.floor((difference / 1000 / 60) % 60); const seconds = Math.floor((difference / 1000) % 60); setTimeLeft({ days, hours, minutes, seconds }); }, 1000); return () => clearInterval(timer); }, []); return (
Boffo Sandwiches Countdown

Next sandwich available in:

{Object.entries(timeLeft).map(([unit, value]) => (
{value} {unit}
))}

Every Sunday at 12:00 PM PST

);};export default CountdownTimer;