time-convertor

Convert time across timezones
git clone http://git.hanabi.in/repos/time-convertor.git
Log | Files | Refs | README | LICENSE

useTime.js (332B)


      1 import React from 'react';
      2 
      3 function useTime() {
      4   const [time, setTime] = React.useState(new Date());
      5   function updateTime() {
      6     setTime(new Date());
      7   }
      8   React.useEffect(() => {
      9     let interval = setInterval(() => updateTime(), 1000);
     10     return () => clearInterval(interval);
     11   });
     12   return time;
     13 }
     14 
     15 export default useTime;