Filter hook 'date_formats'

in WP Core File wp-admin/options-general.php at line 483

View Source

date_formats

Filter Hook
Description
Filters the default date formats.

Hook Information

File Location wp-admin/options-general.php View on GitHub
Hook Type Filter
Line Number 483

Hook Parameters

Type Name Description
string[] $default_date_formats Array of default date formats.

Usage Examples

Basic Usage
<?php
// Hook into date_formats
add_filter('date_formats', 'my_custom_filter', 10, 1);

function my_custom_filter($default_date_formats) {
    // Your custom filtering logic here
    return $default_date_formats;
}

Source Code Context

wp-admin/options-general.php:483 - How this hook is used in WordPress core
<?php
 478  	 * @since 4.0.0 Replaced the `Y/m/d` format with `Y-m-d` (ISO date standard YYYY-MM-DD).
 479  	 * @since 6.8.0 Added the `d.m.Y` format.
 480  	 *
 481  	 * @param string[] $default_date_formats Array of default date formats.
 482  	 */
 483  	$date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y', 'd.m.Y' ) ) );
 484  
 485  	$custom = true;
 486  
 487  foreach ( $date_formats as $format ) {
 488  	echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";

PHP Documentation

<?php
/**
	 * Filters the default date formats.
	 *
	 * @since 2.7.0
	 * @since 4.0.0 Replaced the `Y/m/d` format with `Y-m-d` (ISO date standard YYYY-MM-DD).
	 * @since 6.8.0 Added the `d.m.Y` format.
	 *
	 * @param string[] $default_date_formats Array of default date formats.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-admin/options-general.php
Related Hooks

Related hooks will be displayed here in future updates.