samedi 7 mars 2015

PHP: How to get time of session entry and page exit

I am trying to create a page for a small experiment for my dissertation. I have to measure when a person opens an experimental page and when closes it.


After reading some other questions, I came up with an idea to get the time when the session starts and when a person clicks the button to proceed to another page in a form. Like this:



<?php
session_start();

$_SESSION['timeEnt']= date('H:i:s');
?>

<!DOCTYPE html>
<html>

<form method="post" action="name.php">
<input type="hidden" id="date" name="timeExt" value="" />
<input type="submit" value="Submit!" onclick="document.getElementById('date').value = new Date(<?php date('H:i:s')); ?>" />
</form>

</html>


Unfortunately, later when I get the results I see that the time value in timeEnt is taken from the server and in timeExt from a PC. Another problem is that timeEnt shows a normal format: HH:MM:SS; while timeExt shows e.g. Sat Mar 07 2015 HH:MM:SS GMT+0100


Is there a way to get both from the server and in the same format (HH:MM:SS)?


Thanks


Aucun commentaire:

Enregistrer un commentaire