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
This commit is contained in:
westi 2008-02-23 22:11:47 +00:00
parent 93f0c00cb7
commit 8d42a5d342
4 changed files with 13 additions and 5 deletions

View File

@ -65,7 +65,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
} else { } else {
$t_time = get_the_time(__('Y/m/d g:i:s A')); $t_time = get_the_time(__('Y/m/d g:i:s A'));
$m_time = $post->post_date; $m_time = $post->post_date;
$time = get_post_time(); $time = get_post_time( 'G', true );
if ( ( abs($t_diff = time() - $time) ) < 86400 ) { if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
if ( $t_diff < 0 ) if ( $t_diff < 0 )
$h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );

View File

@ -44,11 +44,11 @@ foreach($posts_columns as $column_name=>$column_display_name) {
if ( 'modified' == $column_name ) { if ( 'modified' == $column_name ) {
$t_time = get_the_modified_time(__('Y/m/d g:i:s A')); $t_time = get_the_modified_time(__('Y/m/d g:i:s A'));
$m_time = $post->post_modified; $m_time = $post->post_modified;
$time = get_post_modified_time(); $time = get_post_modified_time('G', true);
} else { } else {
$t_time = get_the_time(__('Y/m/d g:i:s A')); $t_time = get_the_time(__('Y/m/d g:i:s A'));
$m_time = $post->post_date; $m_time = $post->post_date;
$time = get_post_time(); $time = get_post_time('G', true);
} }
if ( ( abs(time() - $time) ) < 86400 ) { if ( ( abs(time() - $time) ) < 86400 ) {
if ( ( 'future' == $post->post_status) ) if ( ( 'future' == $post->post_status) )

View File

@ -379,11 +379,11 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
if ( 'modified' == $column_name ) { if ( 'modified' == $column_name ) {
$t_time = get_the_modified_time(__('Y/m/d g:i:s A')); $t_time = get_the_modified_time(__('Y/m/d g:i:s A'));
$m_time = $page->post_modified; $m_time = $page->post_modified;
$time = get_post_modified_time(); $time = get_post_modified_time('G', true);
} else { } else {
$t_time = get_the_time(__('Y/m/d g:i:s A')); $t_time = get_the_time(__('Y/m/d g:i:s A'));
$m_time = $page->post_date; $m_time = $page->post_date;
$time = get_post_time(); $time = get_post_time('G', true);
} }
if ( ( abs(time() - $time) ) < 86400 ) { if ( ( abs(time() - $time) ) < 86400 ) {
if ( ( 'future' == $page->post_status) ) if ( ( 'future' == $page->post_status) )

View File

@ -5,6 +5,14 @@ function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
$m = $mysqlstring; $m = $mysqlstring;
if ( empty( $m ) ) if ( empty( $m ) )
return false; 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( $i = mktime(
(int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ), (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 ) (int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 )