I am in need of creating a 5-minute interval timer using react JS, with a 1-minute offset.
The current timer I have functions like this: 1:00 => 1:05 => 1:10 => 1:15 => 1:20.
However, I require it to be adjusted to display: 1:01 => 1:06 => 1:11 => 1:16 => 1:21.
It is essential that the timer stays synchronized with the Los Angeles time-zone.
My goal is to achieve this with the cleanest es7 code possible.
I am working within the NextJS framework.
Below is the code snippet that I currently have:
const [timer, setTimer] = useState("")
const secondPassed = useCallback(() => {
const cur_date = new Date();
const minutes = cur_date.getMinutes();
const seconds = cur_date.getSeconds();
console.log((4 - minutes % 5) + ":" + (seconds >= 50 ? "0" : "") + (59 - seconds))
setTimer(`${(4 - minutes % 5) + ":" + (seconds >= 50 ? "0" : "") + (59 - seconds)}`)
},[])
useEffect(() =>{
setInterval(secondPassed, 1000)
},[])