phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

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.

How many days between the posts


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Tue Jul 20, 2010 9:42 am 
Post subject: How many days between the posts

Hi there!

Lets try to write more posts then the spambots! icon_wink.gif

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.

Anyone an idea?

/Holger
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 449
Location: Québec


flag
PostPosted: Tue Jul 20, 2010 11:17 am 
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 icon_smile.gif

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:

Code:
$my_full_time = explode('.', $b, 2);
$my_hours = $my_full_time[0];
$my_minutes = round($my_full_time[1] * 60);


Of course there are plenty other ways you could be doing this.
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Tue Jul 20, 2010 12:21 pm 
Post subject: Re: How many days between the posts

icon_biggrin.gif
I only want to show the days.

Thank you so far!
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 449
Location: Québec


flag
PostPosted: Tue Jul 20, 2010 2:08 pm 
Post subject: Re: How many days between the posts

Oh, days icon_razz.gif

Let's see, then: 60 * 60 * 24 = 86400 seconds per day. The method itself doesn't change icon_smile.gif

As for not showing it in the first post (didn't understand what you meant earlier, I was just waking up icon_smile.gif), a simple
Code:
if ([difference between A and B] == 0) { /* Make the display variable empty */}
else { /* Display variable = "+$days since original post" */}

should be enough.
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 4 Hours
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0357 seconds using 17 queries. (SQL 0.0081 Parse 0.0005 Other 0.0271)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo