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>;
}