public static function dateFormat($value, string $type = 'date', array $options = []) {
		if (empty($value)) return null;
		$format = $options['format'] ?? self::getDateFormat($type);
		// additional handling for timestamp
		if (is_float($value)) {
			$temp = explode('.', $value . '');
			$value = date('Y-m-d H:i:s', (int) $temp[0]) . (isset($temp[1]) ? '.' . $temp[1] : '');
		}
		try {
			$server_timezone = self::$options['server_timezone_code'] ?? Application::get('php.date.timezone');
			if (is_a($value, 'DateTime')) {
				$object = $value;
			} else {
				$object = new DateTime($value, new DateTimeZone($server_timezone));
			}
			// change timezone
			if (empty($options['skip_user_timezone'])) {
				$object->setTimezone(new DateTimeZone(self::$options['timezone_code']));
			}
			$value = $object->format($format);
		} catch (Exception $e) {
			// on exception we return as is
		}
		// localize
		if (empty($options['skip_i18n'])) {
			$value = str_replace(['am', 'pm'], [i18n(null, 'am', ['skip_i_symbol' => true]), i18n(null, 'pm', ['skip_i_symbol' => true])], $value);
			return self::numberToFromNativeLanguage($value, $options);
		} else {
			return $value;
		}
	}
public static function dateFormat($value, string $type = 'date', array $options = []) {
		if (empty($value)) return null;
		$format = $options['format'] ?? self::getDateFormat($type);
		// additional handling for timestamp
		if (is_float($value)) {
			$temp = explode('.', $value . '');
			$value = date('Y-m-d H:i:s', (int) $temp[0]) . (isset($temp[1]) ? '.' . $temp[1] : '');
		}
		try {
			$server_timezone = self::$options['server_timezone_code'] ?? Application::get('php.date.timezone');
			if (is_a($value, 'DateTime')) {
				$object = $value;
			} else {
				$object = new DateTime($value, new DateTimeZone($server_timezone));
			}
			// change timezone
			if (empty($options['skip_user_timezone'])) {
				$object->setTimezone(new DateTimeZone(self::$options['timezone_code']));
			}
			$value = $object->format($format);
		} catch (Exception $e) {
			// on exception we return as is
		}
		// localize
		if (empty($options['skip_i18n'])) {
			$value = str_replace(['am', 'pm'], [i18n(null, 'am', ['skip_i_symbol' => true]), i18n(null, 'pm', ['skip_i_symbol' => true])], $value);
			return self::numberToFromNativeLanguage($value, $options);
		} else {
			return $value;
		}
	}
public static function dateFormat ( $ value , string $ type = 'date' , array $ options = [ ] ) { if ( empty ( $ value ) ) return null ; $ format = $ options [ 'format' ] ?? self :: getDateFormat ( $ type ) ; // additional handling for timestamp if ( is_float ( $ value ) ) { $ temp = explode ( '.' , $ value . '' ) ; $ value = date ( 'Y-m-d H:i:s' , ( int ) $ temp [ 0 ] ) . ( isset ( $ temp [ 1 ] ) ? '.' . $ temp [ 1 ] : '' ) ; } try { $ server_timezone = self :: $ options [ 'server_timezone_code' ] ?? Application :: get ( 'php.date.timezone' ) ; if ( is_a ( $ value , 'DateTime' ) ) { $ object = $ value ; } else { $ object = new DateTime ( $ value , new DateTimeZone ( $ server_timezone ) ) ; } // change timezone if ( empty ( $ options [ 'skip_user_timezone' ] ) ) { $ object -> setTimezone ( new DateTimeZone ( self :: $ options [ 'timezone_code' ] ) ) ; } $ value = $ object -> format ( $ format ) ; } catch ( Exception $ e ) { // on exception we return as is } // localize if ( empty ( $ options [ 'skip_i18n' ] ) ) { $ value = str_replace ( [ 'am' , 'pm' ] , [ i18n ( null , 'am' , [ 'skip_i_symbol' => true ] ) , i18n ( null , 'pm' , [ 'skip_i_symbol' => true ] ) ] , $ value ) ; return self :: numberToFromNativeLanguage ( $ value , $ options ) ; } else { return $ value ; } }
Format date based on format

@param mixed $value
@param string $type
date
datetime
time
timestamp
@param array $options
format  - for date function
skip_i18n
skip_user_timezone
@return string|NULL
Format date based on format