PHP: Convert the date interval to human-readable format
Convert the date/time interval in human-readable format
$startDate = 'now'; $endDate = '2013-08-12 14:30:00'; function date_diff($date1, $date2) { $diff = strtotime($date2) - strtotime($date1); return abs($diff); } function seconds2human($ss) { $s = $ss % 60; $m = floor(($ss % 3600) / 60); $h = floor(($ss) / 3600); return "$h hours, $m minutes, $s seconds"; } echo "This file will expire in ". seconds2human(date_diff($startDate,$endDate));
Tag: PHP, Date Routines, DateTime, readable
0 Comments