acf_format_date()ACF 5.3.8

acf_format_date

This function will accept a date value and return it in a formatted string

Хуков нет.

Возвращает

$format. (string)

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

acf_format_date( $value, $format );
$value (обязательный)
-
$format (обязательный)
-

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

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

Код acf_format_date() ACF 6.0.4

function acf_format_date( $value, $format ) {

	// bail early if no value
	if ( ! $value ) {
		return $value;
	}

	// vars
	$unixtimestamp = 0;

	// numeric (either unix or YYYYMMDD)
	if ( is_numeric( $value ) && strlen( $value ) !== 8 ) {

		$unixtimestamp = $value;

	} else {

		$unixtimestamp = strtotime( $value );

	}

	// return
	return date_i18n( $format, $unixtimestamp );

}