1
我使用以下格式化日期輸出 - PHP
<?php
function custom_echo($x)
{
if(strlen($x)<=150)
{
echo $x;
}
else
{
$y=substr($x,0,150) . '...';
echo $y;
}
}
// Include the wp-load'er
include('../../blog/wp-load.php');
// Get the last 10 posts
// Returns posts as arrays instead of get_posts' objects
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 4
));
// Do something with them
echo '<div>';
foreach($recent_posts as $post) {
echo '<a class="blog-title" href="', get_permalink($post['ID']), '">', $post['post_title'], '</a><br />', $post['post_date'], custom_echo($post['post_content']), '<br /><br />';
}
echo '</div>';
?>
什麼我遇到的問題是$信息[「POST_DATE」] - 它出來爲2012年12月3日13: 59:56 - 我只想在2012年12月3日閱讀。我不知道如何去做。我知道還有一些其他解決方案與此類似,但我對此並不瞭解,並且真的不理解他們......?
幫助?
謝謝。
這是有趣的 - 我看到文件,但不知道如何實現它。我試過這個說法,但1970年1月1日所有博客文章? – imcconnell
@ user1802256:嘗試做'echo date(「F j,Y」,strtotime($ post ['post_date']));' –
Yep @RocketHazmat是正確的我編輯我的帖子來反映這一點。 – koopajah