acf_format_date()
Returns a date value in a formatted string.
No Hooks.
Returns
String.
Usage
acf_format_date( $value, $format );
- $value(string) (required)
- The date value to format.
- $format(string) (required)
- The format to use.
Changelog
| Since 5.3.8 | Introduced. |
acf_format_date() acf format date code ACF 6.8.8
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 );
}