我正在尝试发布我的日期以显示它在 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
}
?>