The idea is to calculate the seconds that have passed since you entered the page until the button was clicked, using PHP.
The thing is, I want to do this process on the same page, I had previously tried sending the request to a separate page, in plan, the button on a page, and the request that made that button with its respective form , (that is, the action) in another. Unix time passed through a session and subtracted from the current one, in this way I knew the time that had passed.
The problem is that when doing it on the same page, when you click on the button the variables take the same value. And the result is always 0.
Example:
<?php
$time_ = new DateTime();
$c = $time_->getTimestamp();
echo $c;
if(isset($_POST['Palabras']) && strlen($_POST['Palabras'])>0 &&
isset($_POST['Ordenadas']) && strlen($_POST['Ordenadas'])>0){
$t = $time_->getTimestamp();
echo $c - $t;
}
?>
When starting page C always take X value, but when you click on button C and T take the last value obtained.
Any solution?