I want to create a script in php, javascript or jquery which tells me when a post is posted like Facebook in facebook when we post a status it tells us posting time like 5 minute ago or so on. I have completed all other work.
Asked
Active
Viewed 38 times
-1
-
1http://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago – MilanG Feb 21 '15 at 11:11
-
Thu shalt not code for the dark and evil facebook. – arkascha Feb 21 '15 at 11:23
-
please do some research on your own before posting a question with very low quality on stackoverflow. – andyrandy Feb 21 '15 at 12:02
-
luschn, may be it is low quality for you but as a beginner I need some suggestion because I always want to do quality of work. – user3432211 Feb 21 '15 at 16:51
2 Answers
0
You have to create function that will get one parameter "posted date" and it will calculate difference from today. it will generate string and return like "2 days ago/5 min ago" or date. it is depend on you.

Vishal Patel
- 635
- 6
- 12
0
Create a coloumn to the table where you save the post details as posted_at
and have DATETIME
as its data type,
Use $CurrentTime = date("Y-m-d H:i:s" );
and insert while you create the post i.e., insert
So while retrieving the data just find the difference between the posted time and current time by
$PostedTime = strtotime($FetchedData->posted_at) - strtotime(date("Y-m-d H:i:s" ));
Then you shall convert the difference time as per your wish.

Sulthan Allaudeen
- 11,330
- 12
- 48
- 63