MyBB Community Forums

Full Version: Display age in months vs. years
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I run a site where every month is considered a "Year", so those born 5 months ago are actually 5 years old. Is there any way to display age in months vs. years in the profile?

If not, can a custom profile field be added that allows age to be displayed as months? Like they input "February 2015" and it shows "1" and I can custom add a "years old" after ?
Maybe try changing the language file? So it says months instead of years?
(2015-03-04, 04:02 PM)Leefish Wrote: [ -> ]Maybe try changing the language file? So it says months instead of years?

My problem with that is they'd have to change the birth date every month then. Like, a character "born" February 2014 would be 1 year old (in this mod, listed at 1 month old) for an entire year. Vs. if it displayed the age in months they'd be 12 months old (instead of 1 year old). Get my drift?

ie - Tasha was born January 2015, so February 2015 she's 1 year old, March 2015 she's 2 years old, etc. I figured if we would display birthdate in months it'd be easier, because she's <1 year old but accoridng to the game she's 2 years old.

So I've added the following to members.php

Alright, I've found this code works -


$d1 = new DateTime("$membday");
$d2 = new DateTime();
$d3 = $d1->diff($d2);
$months = ($d3->y*12)+$d3->m;

HOWEVER if they do not input a birthday, or hide the birth date, the entire members.php page goes down.

So, what I did was insert

		if($memprofile['birthdayprivacy'] == 'age')
		{
			$membday = $lang->birthdayhidden;
			$months = '';
		}
		else if($memprofile['birthdayprivacy'] == 'none')
		{
			$membday = $lang->birthdayhidden;
			$membdayage = '';
			$months = '';
		}
	}
	else
	{
		$membday = $lang->not_specified;
		$membdayage = '';
		$months = '';
	}
This way, if they don't input anything it just doesn't show up!

[url=//www.pinterest.com/pin/create/extension/][/url]