import React, { useEffect } from "react";
import { View,Text } from "react-native"


const TimeLive = () => {
    const [currentTime, setCurrentTime] = React.useState(new Date());

    useEffect(() => {
        const timer = setInterval(() => {
            setCurrentTime(new Date());
        }, 1000);

        return () => clearInterval(timer);
    }, []);

    const formatDate = (date: Date) => {
        return `${String(date.getDate()).padStart(2, '0')}/${String(date.getMonth() + 1).padStart(2, '0')}/${date.getFullYear()} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;
    };

    return <>
        <View>
            <Text style={{
                fontSize: 12,
                paddingVertical: 10,
                fontWeight: 'bold',
                color: 'white'
            }}>{formatDate(currentTime)}</Text>
        </View>
    </>
}

export default TimeLive;