我正试图让我的约会对象像在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
}
?>
最佳答案
这个问题在stackoverflow中已经问过好几次了,您可以搜索“php time ago”。无论如何,在http://www.php.net/manual/en/function.time.php#89415检查溶液。