Sometime we store timestamp of any event in an integer field in MySQL database instead of storing date and time. Say for example last login time of a user to your forum is stored in MySQL database. After collecting timestamp from table for the user, we can store the last login details like below. We have not discussed how to collect the data from MySQL here , you can read more on this in our MySQL section.
$last_login = new DateTime(); // create a date object
$last_login->setTimestamp(1516245357); // Timestamp of 2018-01-18 08:45:57
$date = new DateTime(); // date object showing current time
echo $date->format('%y Years, %m Months, %d Days'); //1 Years, 0 Months, 15 Days