Registered time function MyBB?

by AndresXZ09 - 11-04-2015, 04:09 PM
Closed Account
Posts:
1,382
Joined:
Jan 2015
Likes:
124
Credits:
1,388
Reputation:
30
3 Years of Service
#1
OP
Posted: 11-04-2015, 04:09 PM
Does someone know about a function related to the registered time?

I want to do something similar to the years of service on LF but I don't know about what function does the work.

Hope you know and can help me.

Thanks :yus:
<div class="postbit-usertitle">
Posts:
642
Joined:
Feb 2015
Likes:
53
Credits:
1,318
Reputation:
35
3 Years of Service
#2
Posted: 11-04-2015, 04:20 PM
(11-04-2015, 04:09 PM)AndresXZ09 Wrote: Does someone know about a function related to the registered time?

I want to do something similar to the years of service on LF but I don't know about what function does the work.

Hope you know and can help me.

Thanks :yus:

Its a custom Plugin
[Image: UeTXrZ5.png]
Closed Account
Posts:
1,382
Joined:
Jan 2015
Likes:
124
Credits:
1,388
Reputation:
30
3 Years of Service
#3
OP
Posted: 11-04-2015, 04:24 PM
(11-04-2015, 04:20 PM)Oxygen Wrote:
(11-04-2015, 04:09 PM)AndresXZ09 Wrote: Does someone know about a function related to the registered time?

I want to do something similar to the years of service on LF but I don't know about what function does the work.

Hope you know and can help me.

Thanks :yus:

Its a custom Plugin

I know, but maybe there is a function that does what I want :noh:
Nan Ihier Gelair Mordor
Divine
Posts:
2,635
Joined:
Jan 2015
Likes:
321
Credits:
8,618
Reputation:
92
3 Years of Service
#4
Posted: 12-04-2015, 03:56 PM
its simple.

Years of service = time() - $member['regdate'];

then convert the timestamp to years. Smile
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.
Closed Account
Posts:
1,382
Joined:
Jan 2015
Likes:
124
Credits:
1,388
Reputation:
30
3 Years of Service
#5
OP
Posted: 12-04-2015, 04:04 PM
(12-04-2015, 03:56 PM)AmN Wrote: its simple.

Years of service = time() - $member['regdate'];

then convert the timestamp to years. Smile

Could you explain mean what do you mean with timestamp? I'm noob with the code :noh:
<div class="postbit-usertitle">
Posts:
642
Joined:
Feb 2015
Likes:
53
Credits:
1,318
Reputation:
35
3 Years of Service
#6
Posted: 12-04-2015, 04:06 PM
(12-04-2015, 04:04 PM)AndresXZ09 Wrote:
(12-04-2015, 03:56 PM)AmN Wrote: its simple.

Years of service = time() - $member['regdate'];

then convert the timestamp to years. Smile

Could you explain mean what do you mean with timestamp? I'm noob with the code :noh:

http://www.unixtimestamp.com/

Converting something like 1428851142 to 04/12/2015 @ 3:05pm (UTC)
[Image: UeTXrZ5.png]
Closed Account
Posts:
1,382
Joined:
Jan 2015
Likes:
124
Credits:
1,388
Reputation:
30
3 Years of Service
#7
OP
Posted: 12-04-2015, 04:08 PM
So the timestamp goes here

time = (133123123) am I right?
Nan Ihier Gelair Mordor
Divine
Posts:
2,635
Joined:
Jan 2015
Likes:
321
Credits:
8,618
Reputation:
92
3 Years of Service
#8
Posted: 12-04-2015, 04:58 PM
huh.

$plugins->add_hook( 'postbit', 'years_of_service' );

function years_of_service(&$post)
{
Code:
$yearsofservice = date( 'Y', TIME_NOW - $post['userregdate'] );
$years = ( $yearsofservice == 1 ) ? 'year' : 'years';
return str_replace( '<years_of_service>',' $yearsofservice . ' ' . $years . ' of service', $post['message'] );
}

and place this in your postbit template: <years_of_service> where you want that stuff to display.
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.
AndresXZ09
12-04-2015, 05:01 PM
Closed Account
Posts:
1,382
Joined:
Jan 2015
Likes:
124
Credits:
1,388
Reputation:
30
3 Years of Service
#9
OP
Posted: 12-04-2015, 05:00 PM
(12-04-2015, 04:58 PM)AmN Wrote: huh.

$plugins->add_hook( 'postbit', 'years_of_service' );

function years_of_service(&$post)
{
Code:
$yearsofservice = date( 'Y', TIME_NOW - $post['userregdate'] );
$years = ( $yearsofservice == 1 ) ? 'year' : 'years';
return str_replace( '<years_of_service>',' $yearsofservice . ' ' . $years . ' of service', $post['message'] );
}

and place this in your postbit template: <years_of_service> where you want that stuff to display.

I wanted to learn actually :noh: but thank you anyway, I'll try to base my plugin on that but with configurable settings on the ACP Tongue
Nan Ihier Gelair Mordor
Divine
Posts:
2,635
Joined:
Jan 2015
Likes:
321
Credits:
8,618
Reputation:
92
3 Years of Service
#10
Posted: 12-04-2015, 05:04 PM
just create a plugin file: amn.php

place my code in it.

add:

Code:
function amn_info()
{
return array(
'name' => 'AmN',
'description' => 'Noh.',
'website' => 'http://askamn.com/',
'author' => 'AmN',
'authorsite' => 'http://askamn.com',
'version' => '1.0',
'compatibility' => '14*,15*,16*,17*,18*',
'guid' => ''
);
}
function amn_activate()
{
//BLA
}
$plugins->add_hook( 'postbit', 'years_of_service' );

function years_of_service(&$post)
{
$yearsofservice = date( 'Y', TIME_NOW - $post['userregdate'] );
$years = ( $yearsofservice == 1 ) ? 'year' : 'years';
return str_replace( '<years_of_service>',' $yearsofservice . ' ' . $years . ' of service', $post['message'] );
}

Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.
The last reply on this thread is older than a month. Please do not unnecessarily bump it.
Register an account or login to reply
Create an account
Create a free account today and start posting right away. It only takes a few seconds.
Login
Log into an existing account.
1 Guest(s)