mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
🔥
This commit is contained in:
parent
452f8a4e16
commit
e1fd388272
15 changed files with 1926 additions and 20 deletions
22
components/Time.tsx
Normal file
22
components/Time.tsx
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { useEffect, useState } from 'react'
|
||||
import styles from 'styles/Home.module.scss'
|
||||
|
||||
const Timer = () => {
|
||||
const [date, setDate] = useState(new Date())
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setDate(new Date())
|
||||
}, 1000)
|
||||
return () => clearInterval(interval)
|
||||
})
|
||||
|
||||
return(
|
||||
<div className={styles.time}>
|
||||
<p><FontAwesomeIcon icon={['fas', 'clock']} /> {date.toLocaleDateString('en-GB', { dateStyle: 'short' }) + ' • ' + date.toLocaleTimeString('en-GB', { timeStyle: 'medium', hour12: true}).toUpperCase()}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Timer
|
Loading…
Add table
Add a link
Reference in a new issue