“Function strftime() is deprecated” in WordPress (PHP 8.1): what it means and the fix

By CompatNav · Published · Last reviewed · 2 min read

Short answer

It’s a deprecation notice from PHP 8.1 and later: a plugin or theme formats a date with strftime(), an old PHP function that relies on the server’s language settings. The date is still printed; PHP only adds a line to the log. The function is on its way out, so the plugin needs a change before a future PHP version removes it. In WordPress the replacement is wp_date(), which uses the site’s own time zone and language. Update the plugin or theme, or send the message to its developer.

The message, exactly

An events plugin prints an event’s date with strftime(). PHP 8.0 runs it silently; PHP 8.1 prints the same date and adds the notice:

wp-content/plugins/event-dates/event-dates.php

<?php
$timestamp = 1798675200; // 31 December 2026, 00:00 UTC
echo strftime('%Y-%m-%d', $timestamp), "\n";

Output on PHP 8.0.30

2026-12-31

Output on PHP 8.1.34

Deprecated: Function strftime() is deprecated in /var/www/html/wp-content/plugins/event-dates/event-dates.php on line 3
2026-12-31

php.net, in the PHP 8.1 deprecations: “strftime() and gmstrftime() have been deprecated. Use date() instead (for locale-independent formatting), or IntlDateFormatter::format() (for locale-dependent formatting).” (php.net)

Is it urgent?

No. A deprecation notice changes nothing on the page: the date is the same. It matters in two ways:

  • Before a future PHP version removes strftime(), the plugin needs its update; after that, the call would stop the page.
  • If your site shows PHP messages on screen, the notice can appear on your pages and break redirects. Log them instead (the WordPress debug log).

Who fixes it

  1. Find the plugin or theme: the folder after wp-content/plugins/ or wp-content/themes/ in the message.
  2. Update it (Dashboard → Updates).
  3. Already on the latest version? Send one full line of the message to its developer.

Found before you switch

The call is in the code, so a check that reads code finds it while your site still runs PHP 8.0 or older:

Other PHP 8.1 notices you’re likely to meet: WordPress and PHP 8.1. All the deprecated functions, with replacements: the PHP deprecated functions list.

Key takeaways

  • A deprecation notice from PHP 8.1 and later: the date still appears, PHP adds a log line.
  • gmstrftime() has the same notice; strptime(), date_sunrise() and date_sunset() went the same way in 8.1.
  • The WordPress replacement is wp_date(); outside WordPress, date() or IntlDateFormatter.
  • The formats differ: %Y-%m-%d in strftime() is Y-m-d in date() and wp_date().
  • A check that reads code finds every call before you upgrade.

Frequently asked questions

Will my dates stop showing?

Not on PHP 8.1 to 8.5: the function still works and only adds a deprecation notice. It stops once a future PHP version removes it, which is why the plugin should be updated.

Why did plugins use strftime()?

It printed month and day names in the server’s language. WordPress has its own translation system, and wp_date() prints names in the site’s language without depending on the server.

How do I hide the notice?

Log PHP messages instead of showing them, as in the WordPress debug log guide. The notice then stays out of your pages; the plugin still needs its update.

Check your own site before you upgrade

CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.

Get CompatNav on wordpress.org How it works

Sources

About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.