Comparing unix timestamps in PHP
html, mysql, php
Solution
Use `DateTime` instead, it will make your code much cleaner.
$latest = new DateTime($latest);
$now = new DateTime();
$diff = $latest->diff($now);
echo $diff->format('%y years %m months %d days');
Problem
In PHP I have: ``` $diff = abs(strtotime(date('m/d/Y h:i:s')) - strtotime($latest)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); echo floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); ``` How do I get the difference in seconds? I've tried the following: ``` $diff = abs(strtotime(date('m/d/Y h:i:s')) - strtotime($latest)); ```