Skip to content

Commit 513672b

Browse files
committed
add useTime in readme file
1 parent fbf3c27 commit 513672b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

readme.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ React timer hook is a custom [react hook](https://reactjs.org/docs/hooks-intro.h
44

55
1. Timers (countdown timer) `useTimer`
66
2. Stopwatch (count up timer) `useStopwatch`
7+
3. Time (return current time) `useTime`
78

89

910
#### Note:
@@ -151,6 +152,61 @@ export default function App() {
151152
| reset | function | function to be called to reset stopwatch to 0:0:0:0 |
152153

153154

155+
---
156+
157+
158+
## `useTime`
159+
160+
### Example
161+
162+
```javascript
163+
import React from 'react';
164+
import { useTime } from 'react-timer-hook';
165+
166+
function MyTime() {
167+
const {
168+
seconds,
169+
minutes,
170+
hours,
171+
ampm,
172+
} = useTime({ format: '12-hour'});
173+
174+
return (
175+
<div style={{textAlign: 'center'}}>
176+
<h1>react-timer-hook </h1>
177+
<p>Current Time Demo</p>
178+
<div style={{fontSize: '100px'}}>
179+
<span>{hours}</span>:<span>{minutes}</span>:<span>{seconds}</span><span>{ampm}</span>
180+
</div>
181+
</div>
182+
);
183+
}
184+
185+
export default function App() {
186+
return (
187+
<div>
188+
<MyTime />
189+
</div>
190+
);
191+
}
192+
```
193+
194+
### Settings
195+
196+
| key | Type | Required | Description |
197+
| --- | --- | --- | ---- |
198+
| format | string | No | if set to `12-hour` time will be formatted with am/pm |
199+
200+
### Values
201+
202+
| key | Type | Description |
203+
| --- | --- | ---- |
204+
| seconds | number | seconds value |
205+
| minutes | number | minutes value |
206+
| hours | number | hours value |
207+
| ampm | string | am/pm value if `12-hour` format is used |
208+
209+
154210
---
155211

156212
### Deprecation Warning:

0 commit comments

Comments
 (0)