[ create a new paste ] login | about

Link: http://codepad.org/Bj5LzgR8    [ raw code | output | fork ]

PHP, pasted on Nov 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

$time_str = "2011-11-03T17:27:56Z";

//echo date('d/m/y H:i:s', strtotime($time_str));
$diff = abs(strtotime("now") - strtotime($time_str)); 

$years   = floor($diff / (365*60*60*24)); 
$months  = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); 
$days    = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
$hours   = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); 
$minuts  = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); 
$seconds = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minuts*60)); 
printf("%d years, %d months, %d days, %d hours, %d minuts\n, %d seconds\n", $years, $months, $days, $hours, $minuts, $seconds);


Output:
1
2
0 years, 0 months, 8 days, 0 hours, 40 minuts
, 33 seconds


Create a new paste based on this one


Comments: