Bende bu linkteki fonksiyonu paylasayim. ;)
http://www.php.net/manual/en/function.gregoriantojd.php#97821
Some people might find it useful to use a function that takes in dates
formatted by ISO8601 standards (yyyy-mm-dd):
ISO8601 standardina gore 2 tarih arasindaki farki gün olarak donduruyor.
Yazan birilerine belki lazım olur demis saolsun ;)
(PHP 4, PHP 5) sürümlerinde calisir.
<?php function daysBetweenDate($from, $till) {
/*
*This function will calculate the difference between two given dates.
*
*Please input time by ISO 8601 standards (yyyy-mm-dd).
*i.e: daysBetweenDate('2009-01-01', '2010-01-01');
*This will return 365.
*
*Author: brian [at] slaapkop [dot] net
*May 5th 2010
*/
if($till < $from) {
trigger_error("The date till is before the date from", E_USER_NOTICE
);
}
//Explode date since gregoriantojd() requires mm, dd, yyyy input;
$from = explode('-', $from);
$till = explode('-', $till);
//Calculate date to Julian Day Count with freshly created array $from.
$from = gregoriantojd($from[1], $from[2], $from[0])."<br />";
//Calculate date to Julian Day Count with freshly created array $till.
$till = gregoriantojd($till[1], $till[2], $till[0])."<br />";
//Substract the days $till (largest number) from $from (smallest number)
to get the amount of days
$days = ($till - $from);
//Return the number of days.
return $days;
//Isn't it sad how my comments use more lines than the actual code?
}
?>
Sevgi ve Saygı ile...
Mustafa Kahraman
02 Temmuz 2010 23:58 tarihinde Zekeriya Bozkurt <[email protected]>yazdı:
>
> İlgilenen tüm arkadaşlara çok teşekkürler. Tüm cevapların sonunda aşağıdaki
> gibi bir fonksiyon yazdım. Hiç bir sistem ve Db formatına bağımlı olmadan
> verilen 2 tarih arasındaki gün farkını alıyor. Belki başka birilerinin de
> işine yarar.
>
> Zekeriya BOZKURT
>
> ----------------------------------------
> <?php
>
> function gunfarki($tarih1,$tarih2)
> {
> $YIL1=intval(date("Y",$tarih1));
> $AY1=intval(date("m",$tarih1));
> $GUN1=intval(date("d",$tarih1));
>
> $YIL2=intval(date("Y",$tarih2));
> $AY2=intval(date("m",$tarih2));
> $GUN2=intval(date("d",$tarih2));
>
> $tarih1=gregoriantojd($AY1,$GUN1,$YIL1);
> $tarih2=gregoriantojd($AY2,$GUN2,$YIL2);
>
> $fark=$tarih1 - $tarih2;
>
> return $fark;
> }
>
> $t1=mktime(0,0,0,05,20,2009);
> $t2=mktime(0,0,0,05,10,2010);
>
> echo gunfarki($t1,$t2);
>
> ?>
> -------------------------------------------
>
> ------------------------------
> Yeni Windows 7: Size en uygun bilgisayarı bulun. Daha fazla bilgi
> edinin.<http://windows.microsoft.com/shop>
>
> _______________________________________________
> Linux-programlama mailing list
> [email protected]
> https://liste.linux.org.tr/mailman/listinfo/linux-programlama
> Liste kurallari: http://liste.linux.org.tr/kurallar.php
>
>
_______________________________________________
Linux-programlama mailing list
[email protected]
https://liste.linux.org.tr/mailman/listinfo/linux-programlama
Liste kurallari: http://liste.linux.org.tr/kurallar.php