2009-08-25 7 views
3

날짜를 표시하려면 최근 변경 사항 WordPress 플러그인을 수정합니다. 날짜를 표시 할 수는 있지만 형식을 지정할 수는 없습니다. 예 : mm/dd/yyyy.WordPress 플러그인에서 날짜 서식 지정

post_modified 날짜를 mm/dd/yyyy로 지정하고 싶습니다.

나는

echo '<li>'.$RecentChange->post_modified('m/d/Y'). 

을 tried-- 한 -하지만 플러그인이 게시물을 표시 중지 원인, 일반적으로 사이트를 끊었다.

이 다음은 PHP의 날짜 또는 시간 post_modified RecentChanges-을 가정하고 plugin--

/* define full SQL request */ 
$rc_sql = "SELECT post_date, post_modified, post_title, ID FROM wp_posts WHERE ".$rc_content_sql." ORDER BY post_modified DESC LIMIT ".$rc_number; 

global $wpdb; 
echo $before_widget; 
echo $before_title.$rc_title.$after_title.'<ul>'; 
$RecentChanges = $wpdb->get_results($rc_sql); 

if ($RecentChanges) 
foreach ($RecentChanges as $RecentChange) : 
$rc_url = get_page_link($RecentChange->ID); 
echo '<li>'.$RecentChange->post_modified.' <a href='.$rc_url.'>'.$RecentChange->post_title.'</a></li>'; 
endforeach; 
echo '</ul>'.$after_widget; 
$wpdb->flush(); 
} 
+0

저는 WordPress 2.8.4를 사용하고 있습니다. PHP 버전은 4.3.9입니다. – smackaysmith

답변

1

>에서 관련 덩어리입니다, 당신은 PHP의 날짜 함수에 랩 수 있고 당신이 원하는 방법을 포맷합니다.

date("m/d/Y", $RecentChanges->post_modified); 

그래서, 당신의 줄은 다음과 같을 것이다 다음 post_modified 기능은 단지 게터하고 매개 변수를 사용하지 않기 때문에

echo '<li>'.date("m/d/Y", $RecentChanges->post_modified).' <a href='.$rc_url.'>'.$RecentChange->post_title.'</a></li>'; 

그것은 당신의 코드가 워드 프레스를 깨는 가능성이 높습니다.

<?php 
    mysql2date('m/d/Y', $RecentChange->post_modified); 
?> 

reference를 참조

+0

날짜가 표시되지만 날짜는 1969 년 12 월 31 일입니다. post_modified를 포맷하지 않을 때는 정확한 날짜를 얻습니다. 이것은 진행 상황입니다. 사이트가 파산하지 않았습니다. – smackaysmith