Make WordPress Core

Changes between Initial Version and Version 4 of Ticket #64496


Ignore:
Timestamp:
01/13/2026 02:28:20 AM (2 months ago)
Author:
sabernhardt
Comment:

#60629 reported the error message earlier.

A directory search lists some of the plugins that might filter the 'get_the_time' information.

I removed the PHP 8.3 keyword and PHP compatibility focus.

  • I did not receive errors or warnings when the filtered date was a numeric string or boolean false.
  • A non-numeric string resulted in a fatal error with PHP 8.0.30, and 7.4.33 gave a warning for the same.

Testing

I added var_dump($time); immediately after $time = get_the_time( 'U' ); in wp_dashboard_recent_posts() to show the output type in my local trunk installation. Also, my time zone is UTC-6, which likely explains why the numeric string value is 6 hours different than the integer.

With no plugins, the Activity widget used integers and displayed the relative post dates.

  • int 1768214078 Today, 10:34 am
  • int 1762863730 Nov 11th 2025, 12:22 pm

Simple Location changed get_the_date output to a numeric string, but it still gave the same post dates.

  • string '1768235678' Today, 10:34 am
  • string '1762885330' Nov 11th 2025, 12:22 pm

Hide/Remove Metadata, set to Hide By PHP and Hide published date, returned false in the filter. Then the Activity widget showed today's date without the time, still including the comma and space.

  • boolean false Jan 12th 2026,
  • boolean false Jan 12th 2026,

WP Last Modified Info also can return false with its 'get_the_time' filter, but that specifically does not run in the admin area.

I reproduced the fatal error by returning a string in a custom must-use plugin. add_filter( 'get_the_time', function ( $the_time ) { return 'gotcha'; } );

  • string 'gotcha'
    ( ! ) Fatal error: Uncaught TypeError: gmdate(): Argument #2 ($timestamp) must be of type ?int, string given in ...\wp-admin\includes\dashboard.php on line 1017
    ( ! ) TypeError: gmdate(): Argument #2 ($timestamp) must be of type ?int, string given in ...\wp-admin\includes\dashboard.php on line 1017
    

Correcting

Plugin filters could need to avoid changing the 'get_the_time' output when is_admin or when the $format is 'U'.

If Core should update the Activity widget, I think it could change the list item <span> contents if the timestamp is not an integer. Casting to an integer might work with the Simple Location plugin, but other non-integer values are likely inappropriate (for comparison or display).

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #64496

    • Property Keywords reporter-feedback added; php8.3 removed
    • Property Focuses php-compatibility removed
    • Property Summary changed from Uncaught Error: gmdate(): Argument #2 ($timestamp) must be of type ?int, string given in wp-admin/includes/dashboard.php on line 1017 to Type Error with gmdate() in dashboard Activity widget
  • Ticket #64496 – Description

    initial v4  
     1{{{
    12Uncaught Error: gmdate(): Argument #2 ($timestamp) must be of type ?int, string given
    23in wp-admin/includes/dashboard.php on line 1017
     
    56
    67gmdate()
     8wp-admin/includes/dashboard.php:1017
    79
    8 wp-admin/includes/dashboard.php:1017
    910wp_dashboard_recent_posts()
     11wp-admin/includes/dashboard.php:940
    1012
    11 wp-admin/includes/dashboard.php:940
    1213wp_dashboard_site_activity()
     14wp-admin/includes/template.php:1453
    1315
    14 wp-admin/includes/template.php:1453
    1516do_meta_boxes()
     17wp-admin/includes/dashboard.php:271
    1618
    17 wp-admin/includes/dashboard.php:271
    1819wp_dashboard()
     20wp-admin/index.php:204
    1921
    20 wp-admin/index.php:204
    2122Query Monitor
     23}}}