[wp-trac] [WordPress Trac] #32386: Draft's Last Modified date incorrect if it is Scheduled

WordPress Trac noreply at wordpress.org
Wed Oct 7 14:46:41 UTC 2020


#32386: Draft's Last Modified date incorrect if it is Scheduled
--------------------------+---------------------------------
 Reporter:  lastnode      |       Owner:  obenland
     Type:  defect (bug)  |      Status:  assigned
 Priority:  normal        |   Milestone:  Future Release
Component:  Date/Time     |     Version:  4.2.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  ui, administration
--------------------------+---------------------------------

Comment (by christopherdarling):

 Noticed this today on 5.5.1 and surprised to see it backdates 5 years.
 This also occurs for me when leaving the Scheduled date as 'Immediately',
 any subsequent changes to the draft post show the original datetime of
 when the post was first saved. Incase it helps anyone, I've used the
 following filter to solve the issue for me.

 {{{#!php
 add_filter( 'post_date_column_time', function ($t_time, $post,
 $column_name, $mode) {
     # If the post type is Draft, use the last modified timestamp
     if ( $post->post_status === 'draft' ) {
         $t_time = sprintf(
             /* translators: 1: Post date, 2: Post time. */
             __( '%1$s at %2$s' ),
             /* translators: Post date format. See https://www.php.net/date
 */
             get_the_modified_time( __( 'Y/m/d' ), $post ),
             /* translators: Post time format. See https://www.php.net/date
 */
             get_the_modified_time( __( 'g:i a' ), $post )
         );
     }

     return $t_time;
 }, 10, 4 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/32386#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list