I want to show the current time(MM/DD/YY hh:mm:ss) in react native app like a clock, and get update every seconds, I tried using new Date() and set it in state, but the time don
in react hooks, it can be done like this:
import React, { useState, useEffect } from "react"; const [dt, setDt] = useState(new Date().toLocaleString()); useEffect(() => { let secTimer = setInterval( () => { setDt(new Date().toLocaleString()) },1000) return () => clearInterval(secTimer); }, []);