final public function formatDateTime($prop, $format=NULL) {

		if (!is_a($this->$prop, 'DateTime')) {
			return NULL;
		}

		$app = Application::getInstance();
		
		// for guests, use default TimeZone
		if (is_a($app->currentUser, 'User')) {
			$dtz = $app->currentUser->getDateTimeZone();
		} else {
			$dtz = new \DateTimeZone(BASE_TIMEZONE);
		}
		
		$this->$prop->setTimeZone($dtz);

		// check if format is specified
		if (!$format) {

			$tran = Translator::getInstance();

			// if is set a locale date format, use it
			if ($tran->stringExists('LC_DATETIME_FORMAT')) {

				return strftime(Translator::do('LC_DATETIME_FORMAT'), $this->$prop->getTimestamp());

			// otherwise choose another format
			} else {
				
				$format = $tran->stringExists('DATETIME_FORMAT') ? Translator::do('DATETIME_FORMAT') : 'Y-m-d H:i:s';
				
			}
			
		}
		
		return $this->$prop->format($format);

	}
final public function formatDateTime($prop, $format=NULL) {

		if (!is_a($this->$prop, 'DateTime')) {
			return NULL;
		}

		$app = Application::getInstance();
		
		// for guests, use default TimeZone
		if (is_a($app->currentUser, 'User')) {
			$dtz = $app->currentUser->getDateTimeZone();
		} else {
			$dtz = new \DateTimeZone(BASE_TIMEZONE);
		}
		
		$this->$prop->setTimeZone($dtz);

		// check if format is specified
		if (!$format) {

			$tran = Translator::getInstance();

			// if is set a locale date format, use it
			if ($tran->stringExists('LC_DATETIME_FORMAT')) {

				return strftime(Translator::do('LC_DATETIME_FORMAT'), $this->$prop->getTimestamp());

			// otherwise choose another format
			} else {
				
				$format = $tran->stringExists('DATETIME_FORMAT') ? Translator::do('DATETIME_FORMAT') : 'Y-m-d H:i:s';
				
			}
			
		}
		
		return $this->$prop->format($format);

	}
final public function formatDateTime ( $ prop , $ format = NULL ) { if ( ! is_a ( $ this -> $ prop , 'DateTime' ) ) { return NULL ; } $ app = Application :: getInstance ( ) ; // for guests, use default TimeZone if ( is_a ( $ app -> currentUser , 'User' ) ) { $ dtz = $ app -> currentUser -> getDateTimeZone ( ) ; } else { $ dtz = new \ DateTimeZone ( BASE_TIMEZONE ) ; } $ this -> $ prop -> setTimeZone ( $ dtz ) ; // check if format is specified if ( ! $ format ) { $ tran = Translator :: getInstance ( ) ; // if is set a locale date format, use it if ( $ tran -> stringExists ( 'LC_DATETIME_FORMAT' ) ) { return strftime ( Translator :: do ( 'LC_DATETIME_FORMAT' ) , $ this -> $ prop -> getTimestamp ( ) ) ; // otherwise choose another format } else { $ format = $ tran -> stringExists ( 'DATETIME_FORMAT' ) ? Translator :: do ( 'DATETIME_FORMAT' ) : 'Y-m-d H:i:s' ; } } return $ this -> $ prop -> format ( $ format ) ; }
Safely formats and returns a DateTime if valid. If language string LC_DATETIME_FORMAT
is set, a locale translated date is returned.

@param	string	Property name of DateTime object.
@param	string	Optional date format, if not passed will get format by language strings.

@return	string|NULL
Safely formats and returns a DateTime if valid . If language string LC_DATETIME_FORMAT is set a locale translated date is returned .