Filter uncanny-automator

automator_time_format

Filters the time format string used throughout the plugin for displaying times.

add_filter( 'automator_time_format', $callback, 10, 1 );

Description

Filters the default time format string used throughout the plugin. Developers can modify this to customize how time is displayed in recipes and other areas, for example, to use 24-hour format or include seconds. The hook fires when the time format is accessed.


Usage

add_filter( 'automator_time_format', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

// Modify the time format to include seconds, for example, when displaying in admin logs.
add_filter( 'automator_time_format', 'my_automator_custom_time_format', 10, 1 );
function my_automator_custom_time_format( $time_format ) {
    // Check if the current context is for detailed logging where seconds are useful.
    // This is a hypothetical check; in a real scenario, you might check $_GET/$_POST variables,
    // a global flag, or a specific function being called.
    if ( isset( $_GET['page'] ) && $_GET['page'] === 'automator-logs' ) {
        return 'g:i:s a'; // Example: 10:30:45 am
    }

    // Otherwise, return the default or previously modified format.
    return $time_format;
}

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/core/class-utilities.php:197

public static function automator_get_time_format() {
		return apply_filters( 'automator_time_format', 'g:i a' );
	}


Scroll to Top