Format date of the given string.

@param  mixed  $value
@param  array  $options

@return string|mixed
345275
public function filter($value, array $options = [])
    {
        if ( ! is_string($value) || empty(trim($value)))
            return $value;

        $this->checkOptions($options);

        list($currentFormat, $targetFormat) = array_map('trim', $options);

        return DateTime::createFromFormat($currentFormat, $value)->format($targetFormat);
    }
870313
public static function toFloat($value, array $options = array())
    {
        $options['number_format'] = Zend_Locale_Format::STANDARD;
        return self::toNumber($value, $options);
    }
1275054
public static function enum(&$value, $options = ['enum'=>[], 'strict'=>false, 'default'=>null])
    {
        if (isset($options['enum']) && is_array($options['enum']) && $options['enum'] != []) {
            $value = in_array($value, $options['enum'], isset($options['strict']) && $options['strict']) ?
                $value : (isset($options['default']) ?
                    $options['default'] : current($options['enum']));
        } else {
            $value = isset($options['default']) ? $options['default'] : null;
        }
        return $value;
    }
1225285
public function rawurl($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return rawurlencode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return rawurldecode($value);
        }

        return $value;
    }
1346938
public static function encodeJson($value, int $options = JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION): string
    {
        return \json_encode($value, $options);
    }
1077164
public function month($name, $value = null, $options = [])
    {
        if ($value instanceof DateTime) {
            $value = $value->format('Y-m');
        }

        return $this->input('month', $name, $value, $options);
    }
213287
public function apply($value, $options = [])
    {
        if (!$value) {
            return $value;
        }
        if (sizeof($options) != 2) {
            throw new InvalidArgumentException('The Sanitizer Format Date filter requires both the current date format as well as the target format.');
        }
        $currentFormat = trim($options[0]);
        $targetFormat  = trim($options[1]);
        return Carbon::createFromFormat($currentFormat, $value)->format($targetFormat);
    }
534220
public static function niceTimestamp($value, array $options = []) {
		if (!isset($value)) return '';
		try {
			$server_timezone = self::$options['server_timezone_code'] ?? Application::get('php.date.timezone');
			$object = new DateTime($value, new DateTimeZone($server_timezone));
			// change timezone
			if (empty($options['skip_user_timezone'])) {
				$object->setTimezone(new DateTimeZone(self::$options['timezone_code']));
			}
			// now and date
			$now = new DateTime('now', new DateTimeZone($server_timezone));
			$other = new DateTime($object->format(self::getDateFormat('date')), new DateTimeZone($server_timezone));
			// if its today we show time
			if ($now->diff($other)->days === 0) {
				$value = $object->format(self::getDateFormat('time'));
			} else {
				$value = $object->format(self::getDateFormat('date'));
			}
		} catch (Exception $e) {
			// on exception we return as is
		}
		return $value;
	}
1000431
protected function pack($field, $value, $options) {
        switch ($options['type']) {
            case 'int':
                return intval($value);
            case 'float':
                return floatval($value);
            case 'list':
                return implode(',', $value);
            case 'array':
            case 'json':
                return @json_encode($value);
            case 'bool':
                return in_array(strtolower($value), ['on', 'yes', '1', 'enabled']) ? 1 : 0;
            case 'datetime':
            case 'date':
                $time = $value ? @strtotime($value) : 0;

                return $time === false ? 0 : $time;
            case 'number':
                if ($options['typef']) {
                    $typef = intval(trim($options['typef']));

                    return number_format($value, $typef, '.', '');
                } else {
                    return number_format($value, 3, '.', '');
                }
            default:
                return $value;
        }
    }
292780
public static function format(string $value)
    {
        $value = explode(',', $value);
        if (!is_array($value)) {
            $value = [$value];
        }
        return $value;
    }
198607
public static function format(string $string, array $values, $options = null) : string
    {
        if ($options instanceof Settings) {
            $settings = $options;
        } elseif (is_array($options)) {
            $settings = new Settings($options);
        } else {
            $settings = new Settings();
        }

        $settings->hasRequiredSettings();

        return self::parseString($string, $values, $settings);
    }
1333139
public function format($value, $params = null, $locale = null) {
		if ($locale === null) {
			$locale = 'en';
		}
		
		return $this->getFormatter($locale)->format($value);
	}
401976
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;
		}
	}
766840
public function renderValue($value, array $options = []): string
    {
        $resolver = new OptionsResolver();
        $this->configureOptions($resolver);
        $options = $resolver->resolve($options);

        if ($value instanceof \DateTimeInterface) {
            if (null !== $options['date_format']) {
                return (string) $value->format($options['date_format']);
            }
            if ($value->format('H:i') === '00:00') {
                $options['time_type'] = \IntlDateFormatter::NONE;
            }
            $dateFormatter = new \IntlDateFormatter(
                $this->translator->getLocale(),
                $options['date_type'],
                $options['time_type']
            );

            return (string) $dateFormatter->format($value);
        }
        if (\is_int($value)) {
            return (string) $value;
        }
        if (\is_float($value)) {
            if (null !== $options['decimals'] || null !== $options['dec_point'] || null !== $options['thousands_sep']) {
                return number_format(
                    $value,
                    $options['decimals'] ?: 2,
                    $options['dec_point'] ?: '.',
                    $options['thousands_sep'] ?: ','
                );
            }
            $numberFormatter = new \NumberFormatter($this->translator->getLocale(), $options['number_format']);

            return (string) $numberFormatter->format($value);
        }
        if (\is_iterable($value)) {
            $items = [];
            /** @noinspection ForeachSourceInspection */
            foreach ($value as $key => $item) {
                $rendered = $this->renderValue($item, $options);
                if (!is_numeric($key)) {
                    $rendered = $key.$options['key_value_separator'].$rendered;
                }
                $items[] = $rendered;
            }

            return implode($options['array_glue'], $items);
        }
        if (\is_bool($value)) {
            if ($options['bool_use_translator']) {
                return (string) $this->translator->trans(
                    $value ? $options['bool_true'] : $options['bool_false']
                );
            }

            return $value ? $options['bool_true'] : $options['bool_false'];
        }

        return (string) $value;
    }
1041243
public static function convert($value, $options = null)
    {
        if ($options === null) {
            $options = self::$options;
        }

        switch (strtolower($value)) {
            case 'true':
                return ($options & self::CONVERT_BOOL) ? true : $value;

            case 'false':
                return ($options & self::CONVERT_BOOL) ? false : $value;

            case 'null':
                return ($options & self::CONVERT_NULL) ? null : $value;
        }

        if (($options & self::CONVERT_INT) && ctype_digit($value)) {
            return (int) $value;
        }

        if (($options & self::STRIP_QUOTES) && !empty($value)) {
            return self::stripQuotes($value);
        }

        return $value;
    }
1239422
protected function formatValue($value)
    {
        // If the value is a date we'll format it according to the specified
        // date format.
        if ($value instanceof DateTime || $value instanceof Carbon)
        {
            $value = $value->format($this->grammar->getDateFormat());
        }

        return $value;
    }
242961
public function serialize($value, array $options=[])
    {

        $serialized = json_encode(
            $value,
            $this->bitmask($options),
            $this->getDepth($options)
        );

        return $serialized;

    }