From 8d42a5d342962d6384c3542e908972488bc2c263 Mon Sep 17 00:00:00 2001 From: westi Date: Sat, 23 Feb 2008 22:11:47 +0000 Subject: [PATCH] Fix the display of human time difference when server timezone if different from blog timezone. Fixes #5970 props jhodgdon. git-svn-id: http://svn.automattic.com/wordpress/trunk@6995 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-attachment-rows.php | 2 +- wp-admin/edit-post-rows.php | 4 ++-- wp-admin/includes/template.php | 4 ++-- wp-includes/functions.php | 8 ++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php index e418f5e3b8..cd0c9ab458 100644 --- a/wp-admin/edit-attachment-rows.php +++ b/wp-admin/edit-attachment-rows.php @@ -65,7 +65,7 @@ foreach($posts_columns as $column_name=>$column_display_name) { } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; - $time = get_post_time(); + $time = get_post_time( 'G', true ); if ( ( abs($t_diff = time() - $time) ) < 86400 ) { if ( $t_diff < 0 ) $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); diff --git a/wp-admin/edit-post-rows.php b/wp-admin/edit-post-rows.php index 3de1ff66f6..20c4d636c9 100644 --- a/wp-admin/edit-post-rows.php +++ b/wp-admin/edit-post-rows.php @@ -44,11 +44,11 @@ foreach($posts_columns as $column_name=>$column_display_name) { if ( 'modified' == $column_name ) { $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); $m_time = $post->post_modified; - $time = get_post_modified_time(); + $time = get_post_modified_time('G', true); } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; - $time = get_post_time(); + $time = get_post_time('G', true); } if ( ( abs(time() - $time) ) < 86400 ) { if ( ( 'future' == $post->post_status) ) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index e00ca0f867..955b36a2d5 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -379,11 +379,11 @@ foreach ($posts_columns as $column_name=>$column_display_name) { if ( 'modified' == $column_name ) { $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); $m_time = $page->post_modified; - $time = get_post_modified_time(); + $time = get_post_modified_time('G', true); } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $page->post_date; - $time = get_post_time(); + $time = get_post_time('G', true); } if ( ( abs(time() - $time) ) < 86400 ) { if ( ( 'future' == $page->post_status) ) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 7987d297ef..1e278b0060 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -5,6 +5,14 @@ function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) { $m = $mysqlstring; if ( empty( $m ) ) return false; + + if( 'G' == $dateformatstring ) { + return gmmktime( + (int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ), + (int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 ) + ); + } + $i = mktime( (int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ), (int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 )