【发布时间】:2013-04-15 05:38:56
【问题描述】:
我正在尝试将我的日期发布为在 youtube 上显示,即。 “2 天前”或“4 小时前”。
当我提取发布日期时,它只显示为“2012-01-11T20:49:59.00Z”
这是我当前的代码;
<?php
// set feed URL
$feedURL = 'https://gdata.youtube.com/feeds/api/users/RiotGamesInc/uploads?max-results=7';
// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);
?>
<?php
// iterate over entries in feed
foreach ($sxml->entry as $entry) {
// get nodes in media: namespace for media information
$media = $entry->children('http://search.yahoo.com/mrss/');
// get video player URL
$attrs = $media->group->player->attributes();
$watch = $attrs['url'];
// get video thumbnail
$attrs = $media->group->thumbnail[1]->attributes();
$thumbnail = $attrs['url'];
?>
<div class="youtubefeed">
<a href="<?php echo $watch; ?>"><img src="<?php echo $thumbnail;?>" /></a></br>
<?php echo $entry->published; ?>
</div>
<?php
}
?>
【问题讨论】:
标签: php html xml youtube-api