I need to format the pubDate to example :
2 hours ago, 2 days ago or 20 hours ago ....
while keeping the original date of the feed cause i tried to format before and i get all my feeds same pubDate the one i set in Date format and the date builder. How can i solve this issue ?
As well i tried to format the text of my pubdate and (Read full article ) when i run pipe its perfect but in pipe output and when i call the rss file from my website i always get the format as code.
You help will be greatly appreciated...
function ShowDate($date) // $date --> time(); value
{
$stf = 0;
$cur_time = time();
$diff = $cur_time - $date;
$phrase = array('second','minute','hour','day','week','month','year','decade');
$length = array(1,60,3600,86400,604800,2630880,31570560,315705600);
for($i =sizeof($length)-1; ($i >=0)&&(($no = $diff/$length[$i])< =1); $i--); if($i < 0) $i=0; $_time = $cur_time -($diff%$length[$i]);
$no = floor($no); if($no <> 1) $phrase[$i] .='s'; $value=sprintf("%d %s ",$no,$phrase[$i]);
if(($stf == 1)&&($i >= 1)&&(($cur_tm-$_time) > 0)) $value .= time_ago($_time);
return $value.' ago ';
}
You need to pass the date within that and you can get the desire format.
This is php function that will convert the time as a 2 hours ago and so on...
For more further function you can check this link Date time formate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.