Title: wp_ajax_time_format
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_ajax_time_format()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#wp--skip-link--target)

Handles formatting a time via AJAX.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#source)󠁿

    ```php
    function wp_ajax_time_format() {
    	wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/ajax-actions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/ajax-actions.php#L2870)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/ajax-actions.php#L2870-L2872)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#related)󠁿

| Uses | Description | 
| [sanitize_option()](https://developer.wordpress.org/reference/functions/sanitize_option/)`wp-includes/formatting.php` |

Sanitizes various option values based on the nature of the option.

  | 
| [date_i18n()](https://developer.wordpress.org/reference/functions/date_i18n/)`wp-includes/functions.php` |

Retrieves the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds.

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_ajax_time_format/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_ajax_time_format%2F)
before being able to contribute a note or feedback.