feat: init
This commit is contained in:
17
apps/web/core/hooks/use-current-time.tsx
Normal file
17
apps/web/core/hooks/use-current-time.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const useCurrentTime = () => {
|
||||
const [currentTime, setCurrentTime] = useState(new Date());
|
||||
// update the current time every second
|
||||
useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
setCurrentTime(new Date());
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
currentTime,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user