0
我正在開發一個WordPress的小部件,通過RSS源導入體育比分。 RSS提要項目有一個匹配日期和時間,所以它是非常重要的信息。在RSS提要看項目喜歡這樣:[星期六,2015年11月14日15:00:00 +0100],但是當我想這個日期在一個變量:WordPress的RSS訂閱獲取日期是UTC時間
$date = $item->get_date();
,我發現了以下輸出:2015年11月14日下午2:00
正確的時間應該是15:00(本地)。有人知道我如何從RSS提要中獲得正確的時間嗎?
$rss = fetch_feed('http://www.volleybal.nl/application/handlers/export.php?format=rss&type=vereniging&programma=7141&iRegionId=7000');
if (!is_wp_error($rss)) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity();
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
endif;
foreach ($rss_items as $item) :
$splitby = array('Wedstrijd:', 'Datum:', 'Speellocatie:');
$text = esc_html($item->get_description());
$split = explode(' ', $text);
$result = array();
$temp = array();
$date = strtotime($item->get_date());
$day = date('j M', $date);
$time = date('G:i', $date);
endforeach;
出於好奇,將是時區永遠是CET? – Ohgodwhy
你正在獲得'正確的時間'。 '[星期六,2015年11月14日15:00:00 +0100]'是3pm + 1,又是4pm。基本上這個字符串是以UTC,+1表示的。你想要什麼時區? – Practically
我看到我在解釋中犯了一個錯誤。該項目中的時間是15:00:00 +0100,當我用'$ item-> get_date()'得到日期時,我收到下午2:00。 – mikesteeghs