Welcome to all phpBB2 Refugees!This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.
Posted: Tue Jul 20, 2010 1:42 pm Post subject: How many days between the posts
Lets try to write more posts then the spambots!
I would like to add the number of days between posts.
If the first post is written 04 Jun 2010 06:41
and the second 15 Jun 2010 18:03
Then I would like to show it like this:
15 Jun 2010 18:03 (+11)
If possible I would like to eliminate the function in the first post.
Posted: Tue Jul 20, 2010 3:17 pm Post subject: Re: How many days between the posts
I don't have access to my database at the moment so I can't check the specifics, but the PHP for it is extremely simple
I suppose phpBB is just using the time() function to get its time and date. Take post2's time() and subtract post1's time(), suppose you get A. If you just want the hours, divide A by 3600 (seconds) to get B = hours passed between the two posts. Then you can round that up, down or naturally with ceil(B), floor(B) or round(B) so you don't have something like 1.265 hours.
The tougher part is to actually get the approriate values to edit from the code, place your function there and edit the template.
It's also a bit more complicated if you want minutes. Take variable B above and don't round it. Then I think you could use explode('.', B, 2) (replace B with an actual variable), which will give you two variables: the value before the period and the decimals. For instance: