-1

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.

user3432211
  • 21
  • 1
  • 7

2 Answers2

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