Monday, April 8, 2013

How to create facebook or twitter like x-time ago date/time format in PHP?

Q. How to create facebook or twitter like x-time ago date/time format in PHP? Is there any built in function are available? Any help would be appreciated.

A. Its possible with a custom made PHP function. Please find the source to get more idea about this.


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 ,';
}


This function can display time or date as 1 days ago, 2 days ago, etc..

Is it possible to create a facebook page automatically?
Q. The company where I work has a proprietary CMS and we would like it to create facebook pages automatically for each site that will be built on it.
Can I use the faccebook API from my site to automatically create a facebook page for it, without having to go to facebook from my browser?

A. yeah there actualy is a way im not too sure how but there is this program called exelbook that allows workers to secretly go on facebook from there desktop with it looking like a microsoft exel project.

Why did the creator of facebook create facebook?
Q. i just want to know the reason why he created facebook in the beginning. i have a facebook and love facebook but it isn't an addiction to me.

A. He wanted a way for all of the people in his college to communicate and stay connected. You should watch the Social Network, its the whole story of that.




Powered by Yahoo! Answers

No comments:

Post a Comment