<?php
session_start();
function time_stamp($session_time)
{
$session_time=new DateTime();
$post_time=new DateTime();
$time_difference = date_diff($post_time,$session_time);
$time_difference->format('y-m-d h-m-s');
$seconds = $time_difference ;
$minutes = round($time_difference / 60 ); //line 11
$hours = round($time_difference / 3600 ); //line 12
$days = round($time_difference / 86400 ); //line 13
$weeks = round($time_difference / 604800 ); //line 14
$months = round($time_difference / 2419200 ); //line 15
$years = round($time_difference / 29030400 ); //line 16
if($seconds <= 60)
{
echo"$seconds seconds ago"; //line 18
}
else if($minutes <=60)
{
if($minutes==1)
{
echo"one minute ago";
}
else
{
echo"$minutes minutes ago";
}
?>
**
When I submit my post it should show x seconds/minutes etc ago
ERROR MESSAGE
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 11
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 12
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 13
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 14
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 15
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 16
Notice: Object of class DateInterval could not be converted to int in C:xampphtdocssocialhome.php on line 18
Recoverable fatal error: Object of class DateInterval could not be converted to string in C:xampphtdocssocialhome.php on line 20
**
question from:
https://stackoverflow.com/questions/65941760/i-need-to-get-the-difference-between-two-time-stamps-when-i-post-comment-on-the 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…