×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Dylan Lopez
Added: Apr 2, 2018 1:49 PM
Modified: Apr 2, 2018 1:50 PM
Views: 2974
Tags: ago datetime time
  1. $now            = new DateTime(date("Y-m-d H:i:s"));
  2. $videoPosted    = new DateTime($video['Video']['posted_date']);
  3. $interval       = $now->diff($videoPosted);
  4.  
  5. echo $interval->format('%h hours, %m month and %d days ago');
  6.  
  7. //or this function :https://stackoverflow.com/questions/2915864/php-how-to-find-the-time-elapsed-since-a-date-time