Skip to content

useTime ​

Hook that gives you current time in different values

time
test coverage
Last changed: 16 days ago

Installation ​

Library
CLI
Manual
typescript
import { useTime } from '@siberiacancode/reactuse';

Usage ​

typescript
const { seconds, minutes, hours, meridiemHours, day, month, year, timestamp } = useTime();

Demo ​

Api ​

Returns

UseTimeReturn

Type declaration ​

typescript
export interface UseTimeReturn {
  /** The current day of the month (1-31) */
  day: number;
  /** The current hour in 24-hour format (0-23) */
  hours: number;
  /** The current hour in 12-hour format with meridiem type (AM/PM) */
  meridiemHours: { value: number; type: string };
  /** The current minute (0-59) */
  minutes: number;
  /** The current month (1-12) */
  month: number;
  /** The current second (0-59) */
  seconds: number;
  /** The current Unix timestamp in milliseconds */
  timestamp: number;
  /** The current year */
  year: number;
}

Source ​

Source • Demo

Contributors ​

D
debabin
debabin
H
hywax
hywax
S
sereda
sereda

Released under the MIT License.