Skip to content

A lightweight package to keep track of time using React hooks

License

Notifications You must be signed in to change notification settings

hxf31891/react-use-current-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

useCurrentTime - a custom React hook for getting and keeping track of the time

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)

Install

npm install react-use-current-time

Example

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 ) 

}

About

A lightweight package to keep track of time using React hooks

Resources

License

Stars

Watchers

Forks

Packages

No packages published