Cheszy Posted March 21, 2011 Share Posted March 21, 2011 I'm looking for something that shows how long it's posted (30 seconds, 10 minutes, 1 hour, 2 hours, 1 day, 1 week, date) But I don't work with databases, so I hope there's something around like this without databases. Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/ Share on other sites More sharing options...
MatthewJ Posted March 21, 2011 Share Posted March 21, 2011 Huh? Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/#findComment-1190442 Share on other sites More sharing options...
Maq Posted March 21, 2011 Share Posted March 21, 2011 What is 'it'? Please elaborate... Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/#findComment-1190447 Share on other sites More sharing options...
Cheszy Posted March 21, 2011 Author Share Posted March 21, 2011 When I post my updates, I just put the date (March 21, 2011). But I want to have it this way: 33 seconds, 4 minutes, 3 hours, 1 day, 2 days etc etc ago. So I post it in the code like 'March 21, 2011 02:35' and when it's 2:45, it says 10 minutes ago. I know you can do such a thing in a database, but I don't work with databases, so I want to "hand-add" it. But I don't know how. (Hope this is more clear) hahaha sorry! Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/#findComment-1190448 Share on other sites More sharing options...
kenrbnsn Posted March 21, 2011 Share Posted March 21, 2011 Google is your friend. I put in the string "php minutes ago" and http://www.dreamincode.net/code/snippet86.htm was the third result. Ken Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/#findComment-1190457 Share on other sites More sharing options...
Cheszy Posted March 21, 2011 Author Share Posted March 21, 2011 That's what I found too, but I need a code like: turns into: 45 minutes ago. Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/#findComment-1190459 Share on other sites More sharing options...
kenrbnsn Posted March 21, 2011 Share Posted March 21, 2011 Assuming you have the function mentioned on that site in your code, you can do something like: <?php $test_date = "2011-03-21 02:35 PM"; echo time_since(strtotime($test_date)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/231299-date-ago/#findComment-1190471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.