2011-11-29 47 views
0

我有一個簡單的RSS提要來到我的Wordpress站點與PHP,但需要風格和格式。我特別爲格式化'時間戳'而苦苦掙扎。格式PHP中的TimeStamp rss

下面是我的代碼,任何幫助是真棒 -

PHP在文檔的頂部。

<?php 
$doc = new DOMDocument(); 
$feedURL = 'http://www.mysite.net/feed/'; 
$doc->load($feedURL); 
//$doc->setEncoding("UTF8"); 
$itemsArray = array(); 

$items = $doc->getElementsByTagName("item"); 
$itemCounter = 0; 
foreach($items as $item) { 
    $titleInfo = array(); 
    $titles = $item->getElementsByTagName("title"); 
    $title = $titles->item(0)->nodeValue; 

    $timestamps = $item->getElementsByTagName("pubDate"); 
    $timestamp = $timestamps->item(0)->nodeValue; 

    $totalItems = 4; 
    if($itemCounter < $totalItems) {     
     $links = $item->getElementsByTagName("link"); 
     $link = $links->item(0)->nodeValue;      
     array_push($titleInfo, $title, $link, $timestamp, $itemCounter); 
     array_push($itemsArray, $titleInfo); 
     $itemCounter++;       
     } 
} 

?> 

<?php 
    include('../includes/db-connect.php'); 
    include('../includes/queries.php'); 
    include('../includes/imprintArray.php');   
    $imprintChoice = 'tenspeed'; 
    $imprintVar = $imprintChoice; 
    $shortImprint = $imprintarray[$imprintChoice]["shortImprint"]; 
    $imprintCode = $imprintarray[$imprintChoice]["imprintCode"]; 
    $imprintName = $imprintarray[$imprintChoice]["imprintName"]; 
    $imprintColor = $imprintarray[$imprintChoice]["imprintColor"]; 
    $results_sort='pub_date'; 
?> 

下面是加價:

<!--New RC feed area 1121--> 

     <div id="RCbox" style="height:auto; width:100%; background-color:#fff;"> 

     <div class="rightside_titlebox" style=" width: 100%; background: none repeat scroll 0% 0% rgb(255, 159, 35);"> 
     <h1 class="rightside_title">Latest from Recipe Club</h1> 
     </div> 

     <div style="float:left; width:360px; padding:10px; line-height:25px;"> 


    <a href="<?php echo $titleInfo[1]; //LINK ?>" style="color: #466289; font-weight: bold;"><?php echo $titleInfo[0]; //POST TITLE ?></a></p><br /> 

    <?php 
    foreach($itemsArray as $titleInfo) {    
     ?><br />    
     <p><?php echo $titleInfo[2];//TIMESTAMP ?>   
     <?php } ?> 



     </div> 

     <div style="float:right; width: 360px; text-align:center;"> 

     <p style="margin-top:-80px;">[ Logo Here ]</p> 

     </div>   

     </div> 

     <br /> 

     <!--End RC area--> 

的飼料工作,但似乎看起來像:

星期二,2011年11月29日15時07分22秒+0000 Giada在家的意大利麪Ponza

而且我希望它的格式如下:

發佈於2011年11月29日

回答

2

你只需輸出從進料的精確值。

你會希望它先轉換,喜歡的東西:

$timestamp = date('F jS, Y', strtotime($timestamps->item(0)->nodeValue));