A lightweight package (1.9 kB) using React hooks
Useful for clocks, calendars and any where else the current time is displayed.
Returns date object, hours (num), minutes (num), seconds (num), standard (1-12) time (string), and military (0-23) time (string)
npm install react-use-current-time
import React from 'react'
import { useCurrentTime } from 'react-use-current-time'
function MyApp() {
const { date, hours, minutes, seconds, time, military } = useCurrentTime();
console.log('date:', date, 'hours:', hours, 'minutes:', minutes, 'seconds:', seconds, 'time:', time, 'military:' military )
}