IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   PHP (https://www.ircforumlari.net/php/)
-   -   iki tarih arasındaki farkı yıl ay gün saat olarak ayırarak bulmak (https://www.ircforumlari.net/php/628765-iki-tarih-arasindaki-farki-yil-ay-gun-saat-olarak-ayirarak-bulmak.html)

hAte 16 Ekim 2014 15:06

iki tarih arasındaki farkı yıl ay gün saat olarak ayırarak bulmak
 
PHP- Kodu:

<?php
function timeDiff($t1$t2)
{
if(
$t1 $t2)
{
$time1 $t2;
$time2 $t1;
}
else
{
$time1 $t1;
$time2 $t2;
}
$diff = array(
'years' => 0,
'months' => 0,
'weeks' => 0,
'days' => 0,
'hours' => 0,
'minutes' => 0,
'seconds' =>0
);
foreach(array(
'years','months','weeks','days','hours','minutes','seconds')
as 
$unit)
{
while(
TRUE)
{
$next strtotime("+1 $unit"$time1);
if(
$next $time2)
{
$time1 $next;
$diff[$unit]++;
}
else
{
break;
}
}
}
return(
$diff);
}


$start strtotime('2007-01-15 07:35:55');
$end strtotime('2009-11-09 13:01:00');
$diff timeDiff($start$end);
$output "The difference is:";
foreach(
$diff as $unit => $value)
{
echo 
$value $unit,";
}
$output trim($output',');
echo 
$output;
?>



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 04:15.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2025 IRCForumlari.Net Sparhawk