What are some best practices for implementing a server-side countdown in PHP for a browser game?

Issue: Implementing a server-side countdown in PHP for a browser game ensures that the timer is accurate and cannot be manipulated by the client. One way to achieve this is by using PHP to calculate the remaining time on the server and send updates to the client using AJAX requests. PHP Code Snippet:

<?php
// Calculate the end time of the countdown (e.g., 10 minutes from now)
$endTime = time() + 600;

// Send the end time to the client
echo json_encode(['endTime' => $endTime]);

// Client-side JavaScript can then countdown to the end time
?>