src/ShopBundle/objects/db/TShopArticleReview.class.php
public function GetReviewAgeAsString()
    {
        $iNow = time();
        $dYear = date('Y', $iNow);
        $dMonth = date('n', $iNow);
        $dDay = date('j', $iNow);
        $dHour = date('G', $iNow);
        $dMin = date('i', $iNow);
        if ('0' == substr($dMin, 0, 1)) {
            $dMin = substr($dMin, 1);
        }

        $iPreviewDate = strtotime($this->fieldDatecreated);
        $dPreviewYear = date('Y', $iPreviewDate);
        $dPreviewMonth = date('n', $iPreviewDate);
        $dPreviewDay = date('j', $iPreviewDate);
        $dPreviewHour = date('G', $iPreviewDate);
        $dPreviewMin = date('i', $iPreviewDate);
        if ('0' == substr($dPreviewMin, 0, 1)) {
            $dPreviewMin = substr($dPreviewMin, 1);
        }

        $iAgeYear = $dYear - $dPreviewYear;
        $iAgeMonth = $dMonth - $dPreviewMonth;
        $iAgeDay = $dDay - $dPreviewDay;
        $iAgeHour = $dHour - $dPreviewHour;
        $iAgeMin = $dMin - $dPreviewMin;
        if ($iAgeMin >= 30) {
            $iAgeHour += 0.5;
        }

        $aAgeParts = array();
        $oLocal = &TCMSLocal::GetActive();
        if ($iAgeYear > 0) {
            $sName = 'Jahr';
            if ($iAgeYear > 1) {
                $sName = 'Jahren';
            }
            $aAgeParts[] = $iAgeYear.' '.$sName;
        }
        if ($iAgeMonth > 0) {
            $sName = 'Monat';
            if ($iAgeMonth > 1) {
                $sName = 'Monaten';
            }
            $aAgeParts[] = $iAgeMonth.' '.$sName;
        }
        if ($iAgeDay > 0) {
            $sName = 'Tag';
            if ($iAgeDay > 1) {
                $sName = 'Tagen';
            }
            $aAgeParts[] = $iAgeDay.' '.$sName;
        }
        if ($iAgeHour > 0) {
            if (1 == $iAgeHour) {
                $aAgeParts[] = $iAgeDay.' Stunde';
            } elseif ($iAgeHour - floor($iAgeHour) > 0) {
                $aAgeParts[] = $oLocal->FormatNumber($iAgeHour, 1).' Stunden';
            } else {
                $aAgeParts[] = $iAgeHour.' Stunden';
            }
        }

        $sAgeString = implode(', ', $aAgeParts);

        if (empty($sAgeString)) {
            $sAgeString = 'weniger als einer halben Stunde';
        }

        return $sAgeString;
    }
public function GetReviewAgeAsString()
    {
        $iNow = time();
        $dYear = date('Y', $iNow);
        $dMonth = date('n', $iNow);
        $dDay = date('j', $iNow);
        $dHour = date('G', $iNow);
        $dMin = date('i', $iNow);
        if ('0' == substr($dMin, 0, 1)) {
            $dMin = substr($dMin, 1);
        }

        $iPreviewDate = strtotime($this->fieldDatecreated);
        $dPreviewYear = date('Y', $iPreviewDate);
        $dPreviewMonth = date('n', $iPreviewDate);
        $dPreviewDay = date('j', $iPreviewDate);
        $dPreviewHour = date('G', $iPreviewDate);
        $dPreviewMin = date('i', $iPreviewDate);
        if ('0' == substr($dPreviewMin, 0, 1)) {
            $dPreviewMin = substr($dPreviewMin, 1);
        }

        $iAgeYear = $dYear - $dPreviewYear;
        $iAgeMonth = $dMonth - $dPreviewMonth;
        $iAgeDay = $dDay - $dPreviewDay;
        $iAgeHour = $dHour - $dPreviewHour;
        $iAgeMin = $dMin - $dPreviewMin;
        if ($iAgeMin >= 30) {
            $iAgeHour += 0.5;
        }

        $aAgeParts = array();
        $oLocal = &TCMSLocal::GetActive();
        if ($iAgeYear > 0) {
            $sName = 'Jahr';
            if ($iAgeYear > 1) {
                $sName = 'Jahren';
            }
            $aAgeParts[] = $iAgeYear.' '.$sName;
        }
        if ($iAgeMonth > 0) {
            $sName = 'Monat';
            if ($iAgeMonth > 1) {
                $sName = 'Monaten';
            }
            $aAgeParts[] = $iAgeMonth.' '.$sName;
        }
        if ($iAgeDay > 0) {
            $sName = 'Tag';
            if ($iAgeDay > 1) {
                $sName = 'Tagen';
            }
            $aAgeParts[] = $iAgeDay.' '.$sName;
        }
        if ($iAgeHour > 0) {
            if (1 == $iAgeHour) {
                $aAgeParts[] = $iAgeDay.' Stunde';
            } elseif ($iAgeHour - floor($iAgeHour) > 0) {
                $aAgeParts[] = $oLocal->FormatNumber($iAgeHour, 1).' Stunden';
            } else {
                $aAgeParts[] = $iAgeHour.' Stunden';
            }
        }

        $sAgeString = implode(', ', $aAgeParts);

        if (empty($sAgeString)) {
            $sAgeString = 'weniger als einer halben Stunde';
        }

        return $sAgeString;
    }
public function GetReviewAgeAsString ( ) { $ iNow = time ( ) ; $ dYear = date ( 'Y' , $ iNow ) ; $ dMonth = date ( 'n' , $ iNow ) ; $ dDay = date ( 'j' , $ iNow ) ; $ dHour = date ( 'G' , $ iNow ) ; $ dMin = date ( 'i' , $ iNow ) ; if ( '0' == substr ( $ dMin , 0 , 1 ) ) { $ dMin = substr ( $ dMin , 1 ) ; } $ iPreviewDate = strtotime ( $ this -> fieldDatecreated ) ; $ dPreviewYear = date ( 'Y' , $ iPreviewDate ) ; $ dPreviewMonth = date ( 'n' , $ iPreviewDate ) ; $ dPreviewDay = date ( 'j' , $ iPreviewDate ) ; $ dPreviewHour = date ( 'G' , $ iPreviewDate ) ; $ dPreviewMin = date ( 'i' , $ iPreviewDate ) ; if ( '0' == substr ( $ dPreviewMin , 0 , 1 ) ) { $ dPreviewMin = substr ( $ dPreviewMin , 1 ) ; } $ iAgeYear = $ dYear - $ dPreviewYear ; $ iAgeMonth = $ dMonth - $ dPreviewMonth ; $ iAgeDay = $ dDay - $ dPreviewDay ; $ iAgeHour = $ dHour - $ dPreviewHour ; $ iAgeMin = $ dMin - $ dPreviewMin ; if ( $ iAgeMin >= 30 ) { $ iAgeHour += 0.5 ; } $ aAgeParts = array ( ) ; $ oLocal = & TCMSLocal :: GetActive ( ) ; if ( $ iAgeYear > 0 ) { $ sName = 'Jahr' ; if ( $ iAgeYear > 1 ) { $ sName = 'Jahren' ; } $ aAgeParts [ ] = $ iAgeYear . ' ' . $ sName ; } if ( $ iAgeMonth > 0 ) { $ sName = 'Monat' ; if ( $ iAgeMonth > 1 ) { $ sName = 'Monaten' ; } $ aAgeParts [ ] = $ iAgeMonth . ' ' . $ sName ; } if ( $ iAgeDay > 0 ) { $ sName = 'Tag' ; if ( $ iAgeDay > 1 ) { $ sName = 'Tagen' ; } $ aAgeParts [ ] = $ iAgeDay . ' ' . $ sName ; } if ( $ iAgeHour > 0 ) { if ( 1 == $ iAgeHour ) { $ aAgeParts [ ] = $ iAgeDay . ' Stunde' ; } elseif ( $ iAgeHour - floor ( $ iAgeHour ) > 0 ) { $ aAgeParts [ ] = $ oLocal -> FormatNumber ( $ iAgeHour , 1 ) . ' Stunden' ; } else { $ aAgeParts [ ] = $ iAgeHour . ' Stunden' ; } } $ sAgeString = implode ( ', ' , $ aAgeParts ) ; if ( empty ( $ sAgeString ) ) { $ sAgeString = 'weniger als einer halben Stunde' ; } return $ sAgeString ; }
return the age of the review as a string.

@return string
return the age of the review as a string .