Jump to content

  •  

  • Tutorial info Visit support topic

    • Added on: May 20 2009 03:16 PM
    • Date Updated: May 20 2009 03:17 PM
    • Views: 779
     


    * * * * *
    1 Ratings

    Enhanced Joined date: X Days, Y Months and Z Days

    Posted by Adriano Faria on May 20 2009 03:16 PM
    First of all, this tutorial uses GetDateDifference function by tchapin, available on http://php.net/date

    Open admin\sources\base\core.php and find:

    		$member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0;
    		$member['author_reputation']	= ipsRegistry::getClass( 'repCache' )->getReputation( $member['pp_reputation_points'] );
    Add below:

    		$nicedate = IPSTime::GetDateDifference( date('m/d/Y', $member['joined'] ), date('m/d/Y', time() ) );
    		 $member['nicedate'] = $nicedate['NiceString'];
    Find:

    	static public function date_getgmdate( $gmt_stamp )
    		{
    			$tmp = gmdate( 'j,n,Y,G,i,s,w,z,l,F,W,M', $gmt_stamp );
    	
    			list( $day, $month, $year, $hour, $min, $seconds, $wday, $yday, $weekday, $fmon, $week, $smon ) = explode( ',', $tmp );
    	
    			return array(  0		 => $gmt_stamp,
    						   "seconds" => $seconds, //	Numeric representation of seconds	0 to 59
    						   "minutes" => $min,	 //	Numeric representation of minutes	0 to 59
    						   "hours"	 => $hour,	  //	Numeric representation of hours	0 to 23
    						   "mday"	 => $day,	 //	Numeric representation of the day of the month	1 to 31
    						   "wday"	 => $wday,	//	Numeric representation of the day of the week	0 (for Sunday) through 6 (for Saturday)
    						   "mon"	 => $month,   //	Numeric representation of a month	1 through 12
    						   "year"	 => $year,	//	A full numeric representation of a year, 4 digits	Examples: 1999 or 2003
    						   "yday"	 => $yday,	//	Numeric representation of the day of the year	0 through 365
    						   "weekday" => $weekday, //	A full textual representation of the day of the week	Sunday through Saturday
    						   "month"	 => $fmon,	//	A full textual representation of a month, such as January or Mar
    						   "week"	=> $week,	//	Week of the year
    						   "smonth"  => $smon,
    						   "smon"	=> $smon
    						);
    		}
    Add below:

    	static public function GetDateDifference($StartDateString=NULL, $EndDateString=NULL)
    		{
       
    			$ReturnArray = array();
    		   
    			$SDSplit = explode('/',$StartDateString);
    			$StartDate = mktime(0,0,0,$SDSplit[0],$SDSplit[1],$SDSplit[2]);
    		   
    			$EDSplit = explode('/',$EndDateString);
    			$EndDate = mktime(0,0,0,$EDSplit[0],$EDSplit[1],$EDSplit[2]);
    		   
    			$DateDifference = $EndDate-$StartDate;
    		   
    			$ReturnArray['YearsSince'] = $DateDifference/60/60/24/365;
    			$ReturnArray['MonthsSince'] = $DateDifference/60/60/24/365*12;
    			$ReturnArray['DaysSince'] = $DateDifference/60/60/24;
    			$ReturnArray['HoursSince'] = $DateDifference/60/60;
    			$ReturnArray['MinutesSince'] = $DateDifference/60;
    			$ReturnArray['SecondsSince'] = $DateDifference;
       
    			$y1 = date("Y", $StartDate);
    			$m1 = date("m", $StartDate);
    			$d1 = date("d", $StartDate);
    			$y2 = date("Y", $EndDate);
    			$m2 = date("m", $EndDate);
    			$d2 = date("d", $EndDate);
    		   
    			$diff = '';
    			$diff2 = '';
    		   
    			if (($EndDate - $StartDate)<=0) {
    				// Start date is before or equal to end date!
    				$diff = "0 days";
    				$diff2 = "Days: 0";
    			} else {
       
    				$y = $y2 - $y1;
    				$m = $m2 - $m1;
    				$d = $d2 - $d1;
    				$daysInMonth = date("t",$StartDate);
    				if ($d<0) {$m--;$d=$daysInMonth+$d;}
    				if ($m<0) {$y--;$m=12+$m;}
    				$daysInMonth = date("t",$m2);
    			   
    				// Nicestring ("1 year, 1 month, and 5 days")
    				if ($y>0) $diff .= $y==1 ? "1 Year" : "$y Years";
    				if ($y>0 && $m>0) $diff .= ", ";
    				if ($m>0) $diff .= $m==1? "1 Month" : "$m Months";
    				if (($m>0||$y>0) && $d>0) $diff .= " and ";
    				if ($d>0) $diff .= $d==1 ? "1 Day" : "$d Days";
    			   
    				// Nicestring 2 ("Years: 1, Months: 1, Days: 1")
    				if ($y>0) $diff2 .= $y==1 ? "Years: 1" : "Years: $y";
    				if ($y>0 && $m>0) $diff2 .= ", ";
    				if ($m>0) $diff2 .= $m==1? "Months: 1" : "Months: $m";
    				if (($m>0||$y>0) && $d>0) $diff2 .= ", ";
    				if ($d>0) $diff2 .= $d==1 ? "Days: 1" : "Days: $d";
    			}
    		   
    			$ReturnArray['NiceString']  = $diff;
    			$ReturnArray['NiceString2'] = $diff2;
    			return $ReturnArray;
    		}
    Open Admin CP -> :ipb3palette: Look & Feel -> click on your skin -> Global Templates -> userInfoPane.

    Find:

    			<dt>{$this->lang->words['m_joined']}</dt>
    			   <dd>{parse date="$author['joined']" format="joined"}</dd>
    Add below:

    			<dt>&nbsp;</dt>
    			   <dd>{$author['nicedate']}</dd>
    Screenshot:

    imagem.PNG


    Powered by Tutorials 1.4.1 © 2012, by Michael McCune