Saturday, December 22nd, 2007 12:35 AM
If you use the diff command, you will be able to see the difference between the files as shown below:
diff file1 file2
diff -y file1 file2 -W 120 #View side by side
No Comments »
Wednesday, March 28th, 2007 01:13 PM
This function will find the difference between two given times. Does PHP already have a native function for that?
//The difference between 2 given time
function dateDifference($day_1,$day_2) {
$diff = strtotime($day_1) - strtotime($day_2);
$sec = $diff % 60;
$diff = intval($diff / 60);
$min = $diff % 60;
$diff = intval($diff / 60);
$hours = $diff % 24;
$days = intval($diff / 24);
return array($sec,$min,$hours,$days);
}
If you just want the day difference…
$diff = strtotime($day_1) - strtotime($day_2) + 1; //Find the number of seconds
$day_difference = ceil($diff / (60*60*24)) ; //Find how many days that is
This can be done using the DATEDIFF function in MySQL 5
[tags]php,code,date,difference,time[/tags]
No Comments »