Title: PHP Fatal error &#8230; undefined function current_datetime()
Last modified: May 19, 2025

---

# PHP Fatal error … undefined function current_datetime()

 *  [Ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/)
 * When adding the cache date to html output, the plugin uses WordPress 5.3.0+ functions
   and breaks on older WordPress versions:
 *     ```wp-block-code
       [19-May-2025 09:55:23 UTC] PHP Fatal error: Uncaught Error: Call to undefined function current_datetime() in .../wp-content/plugins/wp-fastest-cache/inc/cache.php:1130
       ```
   
 * Seems to be [this change](https://plugins.trac.wordpress.org/changeset?sfp_email=&sfph_mail=&reponame=&new=3239675%40wp-fastest-cache%2Ftrunk%2Finc%2Fcache.php&old=3147781%40wp-fastest-cache%2Ftrunk%2Finc%2Fcache.php&sfp_email=&sfph_mail=)
   in code.
 * As the plugin is marked compatible **WordPress 3.3 or higher**, it should add
   shims for the pre 5.3.0 missing functions `current_datetime` -> `wp_timezone`-
   > `wp_timezone_string`
 * WP Fastest Cache 1.3.7

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18472697)
 * We haven’t updated this data in a long time. Now, at least version 5.3 will be
   required.
 *  Thread Starter [Ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18472755)
 * Too bad, the plugin works fine here also in older classic 4.9.x WordPress installations
   before the `current_datetime` change in plugin.
 * As it seems it would be enough to add these few lines to the plugin to maintain
   existing pre 5.3.0 WordPress compatibility:
 *     ```wp-block-code
       /* Shims for WordPress 5.3.0+ functions in wp-includes/functions.php */if ( !function_exists( 'current_datetime' ) ) {	function current_datetime() {		return new DateTimeImmutable( 'now', wp_timezone() );	}}if ( !function_exists( 'wp_timezone' ) ) {	function wp_timezone() {		return new DateTimeZone( wp_timezone_string() );	}}if ( !function_exists( 'wp_timezone_string' ) ) {	function wp_timezone_string() {		$timezone_string = get_option( 'timezone_string' );		if ( $timezone_string ) {			return $timezone_string;		}		$offset  = (float) get_option( 'gmt_offset' );		$hours   = (int) $offset;		$minutes = ( $offset - $hours );		$sign      = ( $offset < 0 ) ? '-' : '+';		$abs_hour  = abs( $hours );		$abs_mins  = abs( $minutes * 60 );		$tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );		return $tz_offset;	}}
       ```
   
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473103)
 * but it is too old version.
 *  Thread Starter [Ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473384)
 * Edited: Last update date yesterday was only for translated versions of 4.9.26
   and previous branches, see e.g. [german WordPress](https://de.wordpress.org/download/releases/#branch-49)
   changelog.
    -  This reply was modified 1 year ago by [Ov3rfly](https://wordpress.org/support/users/ov3rfly/).
      Reason: Removed, last update yesterday was only for translated versions of
      4.9.x
    -  This reply was modified 1 year ago by [Ov3rfly](https://wordpress.org/support/users/ov3rfly/).
      Reason: Edited
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473385)
 * ok I will fix it and let you know.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473495)
 * I fixed the issue. Can you delete wp fastest cache and download the following
   version to get the latest changes please?
 * [https://downloads.wordpress.org/plugin/wp-fastest-cache.zip](https://downloads.wordpress.org/plugin/wp-fastest-cache.zip)
 *  Thread Starter [Ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473589)
 * Your new linked version works fine again also on older classic 4.9.x WordPress
   installations. But currently it still shows 1.3.7 as version number, that could
   be confusing. Thanks for the quick update!
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473594)
 * I haven’t released a new version yet. I will release it in 30 days.
 * You’re welcome 🙂 If you vote, it would make me so happy.
   [https://wordpress.org/support/plugin/wp-fastest-cache/reviews/](https://wordpress.org/support/plugin/wp-fastest-cache/reviews/)

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘PHP Fatal error … undefined function current_datetime()’ is closed to
new replies.

 * ![](https://ps.w.org/wp-fastest-cache/assets/icon-256x256.png?rev=2064586)
 * [WP Fastest Cache - WordPress Cache Plugin](https://wordpress.org/plugins/wp-fastest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-fastest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-fastest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-fastest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-fastest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-fastest-cache/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * Last activity: [1 year ago](https://wordpress.org/support/topic/php-fatal-error-undefined-function-current_datetime/#post-18473594)
 * Status: not resolved