Filter Dynamic uncanny-continuing-education-credits

{dynamic}_date_time_format

> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Filters the date and time format used for displaying dates and times on your site.

add_filter( '{dynamic}_date_time_format', $callback, 10, 1 );

Description

This dynamic filter hook, constructed as `{dynamic}_date_time_format`, allows developers to modify the date, time, or separator formats used by WordPress utilities. It fires during the formatting process, enabling customization before the output is displayed. Developers can hook into this to implement custom date or time displays or change how dates and times are separated.


Usage

add_filter( '{dynamic}_date_time_format', 'your_function_name', 10, 1 );

Parameters

$date (mixed)
This parameter contains the date format string.

Return Value

The filtered value.


Examples

// Modify the date part of the date/time format to use a different format.
function my_custom_date_time_format( $date ) {
    // Example: Change 'F j, Y' (e.g., January 1, 2023) to 'Y-m-d' (e.g., 2023-01-01).
    return 'Y-m-d';
}
add_filter( 'mypluginprefix_date_time_format', 'my_custom_date_time_format', 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/utilities.php:276
src/utilities.php:277
src/utilities.php:278

public static function set_date_time_format( $date = 'F j, Y', $time = ' g:i a', $separator = ' ' ) {

		$date      = apply_filters( self::$prefix . '_date_time_format', $date );
		$time      = apply_filters( self::$prefix . '_date_time_format', $time );
		$separator = apply_filters( self::$prefix . '_date_time_format', $separator );

		if ( null === self::$date_time_format ) {
			self::$date_time_format = $date . $separator . $time;
		}

		if ( null === self::$date_format ) {
			self::$date_format = $date;
		}

		if ( null === self::$time_format ) {
			self::$time_format = $time;
		}

		return self::$date_time_format;
	}

Scroll to Top