You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
477 B
23 lines
477 B
import { useState, useEffect } from 'react'
|
|
import dayjs from 'dayjs'
|
|
import './index.less';
|
|
|
|
const toStr = () => {
|
|
const now = new Date();
|
|
return dayjs(now).format('HH:mm:ss')
|
|
}
|
|
|
|
export default function Time(props) {
|
|
|
|
const [current, setCurrent] = useState();
|
|
useEffect(() => {
|
|
setCurrent(toStr())
|
|
setInterval(() => {
|
|
setCurrent(toStr())
|
|
}, 1000)
|
|
}, [])
|
|
|
|
return <div className='time'>
|
|
{current}
|
|
</div>;
|
|
} |