如何使用PHP和jquery更新html中经过时间的时间

How can I update the time elapsed without refreshing the page using jquery,

It checks if the time session isset to be displayed time elapsed in seconds

<?php
if (!isset($_SESSION['start_time'][$pId])) {
    $_SESSION['start_time'][$presentId] = time();
}
$end_time = time();

$timeDiff = $end_time - $_SESSION['start_time'][$pId];
?>

form

<form>
    <input type="hidden" name="time_taken" id="quesId_<?php echo $v->id ?>"
           value="<?php echo $timeDiff ?>">
</form>

This displays the time elapsed in the seconds on each page refresh;

<div class="well timer"><i class=" icon-time"></i> <span
        class="response-time"><?php echo $timeDiff ?> </span>
</div>

script

<script>
    $(document).ready(function () {

        //setTimeout(timeUpdate(), 1000);
        function timeUpdate() {
            var time = $("#quesId_<?php echo $pId ?>").val();
            //alert(time);
            console.log(time);
            $('.response-time').text(time);
            setTimeout(timeUpdate(), 1000);
        }

        timeUpdate();


    });
</script>

Thanks @charlietfl

Error was declaring the variable inside the function that has to be outside the function and the timer has to be incremented in every call;

 var time = $("#quesId_<?php echo $pId ?>").val();
            function timeUpdate() {
                //alert(time);
                console.log(time);
                time++;
                $('.response-time').text(time);
                setTimeout(timeUpdate, 1000);
            }

            timeUpdate();