File "home.php"

Full path: /home2/camaradearamari/public_html/cmd/home.php
File size: 1.91 KiB (1952 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php include('src/View/Layout/main.php'); ?>
<main class="content">
    <div class="container-fluid p-0">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <div class="container">
                            <div class="header">
                                <h1>Dashboard</h1>
                                <div class="greeting" id="greeting"></div>
                                <div class="date" id="date"></div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </div>

    </div>
</main>



</body>
<script>
    // Função para obter a saudação com base na hora atual
    function getGreeting() {
        var now = new Date();
        var hour = now.getHours();

        if (hour < 12) {
            return "Bom dia";
        } else if (hour < 18) {
            return "Boa tarde";
        } else {
            return "Boa noite";
        }
    }

    // Função para formatar a data
    function formatDate(date) {
        var options = {
            weekday: 'long',
            year: 'numeric',
            month: 'long',
            day: 'numeric'
        };
        return date.toLocaleDateString('pt-BR', options);
    }

    // Atualiza a saudação e a data/hora na tela
    function updateDashboard() {
        var greetingElement = document.getElementById("greeting");
        var dateElement = document.getElementById("date");
        var now = new Date();

        greetingElement.textContent = getGreeting() + ", <?php echo $_SESSION['email']; ?>!";
        dateElement.textContent = formatDate(now) + " " + now.toLocaleTimeString('pt-BR');
    }

    // Atualiza o dashboard a cada segundo
    setInterval(updateDashboard, 1000);
</script>

</html>

PHP File Manager