source/Core/UtilsDate.php
public function formatDBDate($sDBDateIn, $blForceEnglishRet = false)
    {
        // convert english format to output format
        if (!$sDBDateIn) {
            return null;
        }

        $oStr = getStr();
        if ($blForceEnglishRet && $oStr->strstr($sDBDateIn, '-')) {
            return $sDBDateIn;
        }

        if ($this->isEmptyDate($sDBDateIn) && $sDBDateIn != '-') {
            return '-';
        } elseif ($sDBDateIn == '-') {
            return '0000-00-00 00:00:00';
        }

        // is it a timestamp ?
        if (is_numeric($sDBDateIn)) {
            // db timestamp : 20030322100409
            $sNew = substr($sDBDateIn, 0, 4) . '-' . substr($sDBDateIn, 4, 2) . '-' . substr($sDBDateIn, 6, 2) . ' ';
            // check if it is a timestamp or wrong data: 20030322
            if (strlen($sDBDateIn) > 8) {
                $sNew .= substr($sDBDateIn, 8, 2) . ':' . substr($sDBDateIn, 10, 2) . ':' . substr($sDBDateIn, 12, 2);
            }
            // convert it to english format
            $sDBDateIn = $sNew;
        }

        // remove time as it is same in english as in german
        $aData = explode(' ', trim($sDBDateIn));

        // preparing time array
        $sTime = (isset($aData[1]) && $oStr->strstr($aData[1], ':')) ? $aData[1] : '';
        $aTime = $sTime ? explode(':', $sTime) : [0, 0, 0];

        // preparing date array
        $sDate = isset($aData[0]) ? $aData[0] : '';
        $aDate = preg_split('/[\/.-]/', $sDate);

        // choosing format..
        if ($sTime) {
            $sFormat = $blForceEnglishRet ? 'Y-m-d H:i:s' : \OxidEsales\Eshop\Core\Registry::getLang()->translateString('fullDateFormat');
        } else {
            $sFormat = $blForceEnglishRet ? 'Y-m-d' : \OxidEsales\Eshop\Core\Registry::getLang()->translateString('simpleDateFormat');
        }

        if (count($aDate) != 3) {
            return date($sFormat);
        } else {
            return $this->_processDate($aTime, $aDate, $oStr->strstr($sDate, '.'), $sFormat);
        }
    }
public function formatDBDate($sDBDateIn, $blForceEnglishRet = false)
    {
        // convert english format to output format
        if (!$sDBDateIn) {
            return null;
        }

        $oStr = getStr();
        if ($blForceEnglishRet && $oStr->strstr($sDBDateIn, '-')) {
            return $sDBDateIn;
        }

        if ($this->isEmptyDate($sDBDateIn) && $sDBDateIn != '-') {
            return '-';
        } elseif ($sDBDateIn == '-') {
            return '0000-00-00 00:00:00';
        }

        // is it a timestamp ?
        if (is_numeric($sDBDateIn)) {
            // db timestamp : 20030322100409
            $sNew = substr($sDBDateIn, 0, 4) . '-' . substr($sDBDateIn, 4, 2) . '-' . substr($sDBDateIn, 6, 2) . ' ';
            // check if it is a timestamp or wrong data: 20030322
            if (strlen($sDBDateIn) > 8) {
                $sNew .= substr($sDBDateIn, 8, 2) . ':' . substr($sDBDateIn, 10, 2) . ':' . substr($sDBDateIn, 12, 2);
            }
            // convert it to english format
            $sDBDateIn = $sNew;
        }

        // remove time as it is same in english as in german
        $aData = explode(' ', trim($sDBDateIn));

        // preparing time array
        $sTime = (isset($aData[1]) && $oStr->strstr($aData[1], ':')) ? $aData[1] : '';
        $aTime = $sTime ? explode(':', $sTime) : [0, 0, 0];

        // preparing date array
        $sDate = isset($aData[0]) ? $aData[0] : '';
        $aDate = preg_split('/[\/.-]/', $sDate);

        // choosing format..
        if ($sTime) {
            $sFormat = $blForceEnglishRet ? 'Y-m-d H:i:s' : \OxidEsales\Eshop\Core\Registry::getLang()->translateString('fullDateFormat');
        } else {
            $sFormat = $blForceEnglishRet ? 'Y-m-d' : \OxidEsales\Eshop\Core\Registry::getLang()->translateString('simpleDateFormat');
        }

        if (count($aDate) != 3) {
            return date($sFormat);
        } else {
            return $this->_processDate($aTime, $aDate, $oStr->strstr($sDate, '.'), $sFormat);
        }
    }
public function formatDBDate ( $ sDBDateIn , $ blForceEnglishRet = false ) { // convert english format to output format if ( ! $ sDBDateIn ) { return null ; } $ oStr = getStr ( ) ; if ( $ blForceEnglishRet && $ oStr -> strstr ( $ sDBDateIn , '-' ) ) { return $ sDBDateIn ; } if ( $ this -> isEmptyDate ( $ sDBDateIn ) && $ sDBDateIn != '-' ) { return '-' ; } elseif ( $ sDBDateIn == '-' ) { return '0000-00-00 00:00:00' ; } // is it a timestamp ? if ( is_numeric ( $ sDBDateIn ) ) { // db timestamp : 20030322100409 $ sNew = substr ( $ sDBDateIn , 0 , 4 ) . '-' . substr ( $ sDBDateIn , 4 , 2 ) . '-' . substr ( $ sDBDateIn , 6 , 2 ) . ' ' ; // check if it is a timestamp or wrong data: 20030322 if ( strlen ( $ sDBDateIn ) > 8 ) { $ sNew .= substr ( $ sDBDateIn , 8 , 2 ) . ':' . substr ( $ sDBDateIn , 10 , 2 ) . ':' . substr ( $ sDBDateIn , 12 , 2 ) ; } // convert it to english format $ sDBDateIn = $ sNew ; } // remove time as it is same in english as in german $ aData = explode ( ' ' , trim ( $ sDBDateIn ) ) ; // preparing time array $ sTime = ( isset ( $ aData [ 1 ] ) && $ oStr -> strstr ( $ aData [ 1 ] , ':' ) ) ? $ aData [ 1 ] : '' ; $ aTime = $ sTime ? explode ( ':' , $ sTime ) : [ 0 , 0 , 0 ] ; // preparing date array $ sDate = isset ( $ aData [ 0 ] ) ? $ aData [ 0 ] : '' ; $ aDate = preg_split ( '/[\/.-]/' , $ sDate ) ; // choosing format.. if ( $ sTime ) { $ sFormat = $ blForceEnglishRet ? 'Y-m-d H:i:s' : \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'fullDateFormat' ) ; } else { $ sFormat = $ blForceEnglishRet ? 'Y-m-d' : \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'simpleDateFormat' ) ; } if ( count ( $ aDate ) != 3 ) { return date ( $ sFormat ) ; } else { return $ this -> _processDate ( $ aTime , $ aDate , $ oStr -> strstr ( $ sDate , '.' ) , $ sFormat ) ; } }
Format date to user defined format.

@param string $sDBDateIn         Date to reformat
@param bool   $blForceEnglishRet Force to return primary value(default false)

@return string
Format date to user defined format .