<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>time ago - WP2X</title> <atom:link href="https://wp2x.com/tag/time-ago/feed/" rel="self" type="application/rss+xml" /><link>https://wp2x.com</link> <description>We can help your Wordpress faster</description> <lastBuildDate>Wed, 03 Dec 2014 10:21:56 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod> hourly </sy:updatePeriod> <sy:updateFrequency> 1 </sy:updateFrequency> <generator>https://wordpress.org/?v=5.6.17</generator> <item><title>PHP function to display time ago base on timestamp</title><link>https://wp2x.com/php-function-display-time-ago-base-timestamp/</link> <comments>https://wp2x.com/php-function-display-time-ago-base-timestamp/#comments</comments> <dc:creator><![CDATA[david]]></dc:creator> <pubDate>Wed, 03 Dec 2014 10:21:56 +0000</pubDate> <category><![CDATA[Wordpress Tips]]></category> <category><![CDATA[php function]]></category> <category><![CDATA[php tips]]></category> <category><![CDATA[time ago]]></category> <guid
isPermaLink="false">http://wp2x.com/?p=326</guid><description><![CDATA[<p>Timestamp in PHP only for system usage, for user we have to show it in easy to read way like: 1 minutes ago, 1 hour ago &#8230; Today I will show you to use PHP function to display time ago base on timestamp. Here is very simple PHP function what you can use in any PHP ...</p><p>The post <a
rel="nofollow" href="https://wp2x.com/php-function-display-time-ago-base-timestamp/">PHP function to display time ago base on timestamp</a> appeared first on <a
rel="nofollow" href="https://wp2x.com">WP2X</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Timestamp in PHP only for system usage, for user we have to show it in easy to read way like: 1 minutes ago, 1 hour ago &#8230; Today I will show you to use PHP function to display time ago base on timestamp.<span
id="more-326"></span></p><p><a
href="http://wp2x.com/wp-content/uploads/2014/12/php-function-time-ago.png?4b2a2c&amp;4b2a2c"><img
loading="lazy" class="aligncenter size-full wp-image-327" src="http://wp2x.com/wp-content/uploads/2014/12/php-function-time-ago.png?4b2a2c&amp;4b2a2c" alt="php function time ago" width="728" height="546" srcset="https://wp2x.com/wp-content/uploads/2014/12/php-function-time-ago.png 728w, https://wp2x.com/wp-content/uploads/2014/12/php-function-time-ago-300x225.png 300w" sizes="(max-width: 728px) 100vw, 728px" /></a>Here is very simple PHP function what you can use in any PHP project to display time.</p><pre class="lang:php decode:true ">&lt;?php
function timeAgo($time_ago){
$cur_time 	= time();
$time_elapsed 	= $cur_time - $time_ago;
$seconds 	= $time_elapsed ;
$minutes 	= round($time_elapsed / 60 );
$hours 		= round($time_elapsed / 3600);
$days 		= round($time_elapsed / 86400 );
$weeks 		= round($time_elapsed / 604800);
$months 	= round($time_elapsed / 2600640 );
$years 		= round($time_elapsed / 31207680 );
// Seconds
if($seconds &lt;= 60){
	echo "$seconds seconds ago";
}
//Minutes
else if($minutes &lt;=60){
	if($minutes==1){
		echo "one minute ago";
	}
	else{
		echo "$minutes minutes ago";
	}
}
//Hours
else if($hours &lt;=24){
	if($hours==1){
		echo "an hour ago";
	}else{
		echo "$hours hours ago";
	}
}
//Days
else if($days &lt;= 7){
	if($days==1){
		echo "yesterday";
	}else{
		echo "$days days ago";
	}
}
//Weeks
else if($weeks &lt;= 4.3){
	if($weeks==1){
		echo "a week ago";
	}else{
		echo "$weeks weeks ago";
	}
}
//Months
else if($months &lt;=12){
	if($months==1){
		echo "a month ago";
	}else{
		echo "$months months ago";
	}
}
//Years
else{
	if($years==1){
		echo "one year ago";
	}else{
		echo "$years years ago";
	}
}
}

?&gt;</pre><p>Now, time to show and use it &#8216;s quite simple like this</p><pre class="lang:php decode:true ">&lt;?php
  $curenttime="2013-07-10 09:09:09";
  $time_ago =strtotime($curenttime);
  echo timeAgo($time_ago);
?&gt;</pre><p>You will see the output like this</p><pre class="lang:default decode:true ">one year ago</pre><p>&nbsp;</p><p>&nbsp;</p><p>The post <a
rel="nofollow" href="https://wp2x.com/php-function-display-time-ago-base-timestamp/">PHP function to display time ago base on timestamp</a> appeared first on <a
rel="nofollow" href="https://wp2x.com">WP2X</a>.</p> ]]></content:encoded> <wfw:commentRss>https://wp2x.com/php-function-display-time-ago-base-timestamp/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>