Never forget to add the ;
at the end of the line instruction.
$_SESSION['started'] = $_SERVER['REQUEST_TIME']
This code will only show a value if the session starts for the first time. because isset($_SESSION['started']))
will be false.
In this case, it will only display the timesamp of the the request time.
$_SERVER['REQUEST_TIME']
You must use the date()
function for time formatting
date("H:i",$_SESSION['started'])
where H
is for hour, and i
is for minute.
Never forget also to add the session_start()
function before any printing.
Always close an open HTML tag
print "<td>Today you started work at: " ;
...
print "</td>" ;
Here is a correction:
session_start();
print "<td>Today you started work at: " ;
if (!isset($_SESSION['started'])){
$_SESSION['started'] = $_SERVER['REQUEST_TIME'];
}
print date("H:i",$_SESSION['started']);
print "</td>" ;