First of all you need a route in PHP which can be called by AJAX to set the status in your Database.
If your route works you can implement the countdown in JavaScript with the help of setInterval(...)
.
Example on W3Schools
When the countdown has finished, call your route with AJAX (within your setTimeout
callback).