How to show the seconds running in the date function

0

Good morning, how do I show the seconds running in the function below? can be some function in jQuery to animate php.

date_default_timezone_set('America/sao_paulo');
//CRIA UMA VARIAVEL E ARMAZENA A HORA ATUAL DO FUSO-HORÀRIO DEFINIDO (BRASÍLIA)
$Asuncion = date('H:i:s', time()); 
    
asked by anonymous 16.07.2018 / 16:37

1 answer

2

You can do it via jquery by picking up the client's time.

<!DOCTYPE html>
<html>
<body>

    <p>A script on this page starts this clock:</p>
    <p id="demo"></p>

    <button onclick="myStopFunction()">Stop time</button>

    <script>
    var myVar = setInterval(myTimer, 1000);

    function myTimer() {
        var d = new Date();
        var t = d.toLocaleTimeString();
        document.getElementById("demo").innerHTML = t;
    }

    function myStopFunction() {
        clearInterval(myVar);
    }
</script>

</body>
</html>

Reference: link

Or use setInterval to call a function that performs the ajax request to get the server time in PHP.

I hope I have helped.

    
16.07.2018 / 18:36