Mailinglisten-Archive |
Danke Sebastian, funktioniert
Leider will der Kunde jetzt doch nur die Gesamt-Anzahl der Tage dazwischen.
Dank nochmal an Andreas und MIchael!
Hab den Code aber vorsichtshalber mal in ne Funktion gepackt, falls man
sichs doch anders ubelegt.
Gruss *Joern*
-----Original Message-----
From: php-bounces at phpbar.de [mailto:php-bounces at phpbar.de]On Behalf Of
Sebastian Mendel
Sent: Monday, March 22, 2004 4:37 PM
To: deutschsprachige PHP-Mailingliste
Subject: Re: [php] Zeitabfrage
Sebastian Mendel wrote:
> Sebastian Mendel wrote:
>
>> $days = 0;
>> $month = 0;
>> $years = 0;
>>
>> $start = strtotime('2004-05-12');
>> $end = strtotime('2005-06-12');
>>
>> $days = date('d', $end) - date('d', $start);
>> if ( $days < 0 )
>> {
>> $month--;
>> $days = date('t', $start) - date('d', $start);
>> $days += date('d', $end);
>> }
>>
>> $month += date('n', $end) - date('n', $start);
>> if ( $month < 0 )
>> {
>> $years--;
>> $month = 11;
> $month -= 12; // naja, kleiner tipp-fehler! ;-)
$month += 12; // verdammt!!! was schreib ich hier nur, bei mir hab
ich es schon dei ganze zeit richtig ...
>> }
>>
>> $years += date('y', $end) - date('y', $start);
>>
>> echo $years . ' Jahr(e) ' . $month . ' Monat(e) und ' . $days . '
>> Tag(e).';
--
Sebastian Mendel (www.sebastianmendel.de)
*www.warzonez.de* | www.tekkno4u.de | www.nofetish.com
--
** Allgemeine deutschsprachige PHP-Liste: php at phpbar.de **
Informationen: http://www.phpbar.de
http://lists.phpbar.de/mailman/listinfo/php
php::bar PHP Wiki - Listenarchive