It is required to know the difference in seconds between two DateTime objects. By a certain amount of ordeal, the following happened:
<?php session_start(); $_SESSION['previousAccessTime'] = $_SESSION['currentAccessTime']; $_SESSION['currentAccessTime'] = new DateTime(); echo $_SESSION['previousAccessTime']->format("h:i:s"), " - ", $_SESSION['currentAccessTime']->format("h:i:s"), "<br>"; $interval = strtotime($_SESSION['currentAccessTime']->format("h:i:s")) - strtotime($_SESSION['previousAccessTime']->format("h:i:s")); echo $interval; ?> It works and the difference in seconds between the two marks is placed in the $ interval ... But the feeling is that I am doing something wrong. Perhaps this feeling is connected with the method of obtaining this difference, in which I get a string from a DateTime object, and then turn it into a time object. As far as this solution to the problem is crooked, the feeling that I have a pile of a crutch does not leave me, and I do not want to do that.