guys. I have a feature on my PHP app where I need to count-down (or up).
My clients will start a session that will run for a variable amount of time. I need to display the status of this session, in real-time (or close to) on the page.
For example, client one can start a session at 2016-10-04 12:50:00 and that session will run for nine minutes. I am pulling the start time and duration from the database but have hard-coded them here for ease of reading.
$timeStarted = new DateTime('2016-10-04 12:40:00'); //DYNAMIC
$timeEnding = $timeStarted->modify('+9 minutes'); // DYNAMIC
$timeStartedFormatted = $timeStarted->format('Y-m-d H:i:s');
$timeEndingFormatted = $timeEnding->format('Y-m-d H:i:s');
echo "<span id='timeStarted'>".$timeStartedFormatted."</span>";
echo "<span id='timeEnding'>".$timeEndingFormatted."</span>";
As you can see, I have saved the start time and end time in a span to be picked up by jQuery.
What I need to do is display a timer of this session on the page.
For example:
Session 1: 2/9 minutes. Which counts up as the minutes tick on and then stops at the end of the session.
Can anyone help me with this please?
Many thanks in advance, Mark