acf_format_date()ACF 5.3.8

Returns a date value in a formatted string.

Хуков нет.

Возвращает

Строку.

Использование

acf_format_date( $value, $format );
$value(строка) (обязательный)
The date value to format.
$format(строка) (обязательный)
The format to use.

Список изменений

С версии 5.3.8 Введена.

Код acf_format_date() ACF 6.4.2

function acf_format_date( $value, $format ) {
	// Bail early if no value or value is not what we expect.
	if ( ! $value || ( ! is_string( $value ) && ! is_int( $value ) ) ) {
		return $value;
	}

	// Numeric (either unix or YYYYMMDD).
	if ( is_numeric( $value ) && strlen( $value ) !== 8 ) {
		$unixtimestamp = $value;
	} else {
		$unixtimestamp = strtotime( $value );
	}

	return date_i18n( $format, $unixtimestamp );
}