MyBB Community Forums

Full Version: <blank> years of service
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Ok...you're right, but this should work:
<?php
switch($x)
{
  case ($post['regdate']+(60*60*24*30) <= TIME_NOW):
  echo '<div class="postbit-time-1month">1 month on MMH</div>';
  break;
 
  case ($post['regdate']+(60*60*24*62) <= TIME_NOW):
  echo '<div class="postbit-time-2month">2 months on MMH</div>';
  break;
  
  case ($post['regdate']+(60*60*24*182) <= TIME_NOW):
  echo '<div class="postbit-time-halfyear">1/2 year on MMH</div>';
  break;
  
  case ($post['regdate']+(60*60*24*365) <= TIME_NOW):
  echo '<div class="postbit-time-year">1 year on MMH</div>';
  break;
 
  default:
  echo '';
  break;
}
echo $x;
?>
How can you remove 0 years of service lol?
very useful thanks for posting
(2015-07-19, 09:10 AM)Krytic Wrote: [ -> ]Or:

<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<span class="service-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} years of service</span>

(The number will be an integer, ie 1, 2, 3, instead of one, two, three)

Then, in global.css, stuff like this works:

.service-1 {
color: pink;
}

.service-2 {
color: yellow;
}

.service-3 {
color: red;
}

.service-4 {
color: orange;
}

et cetera, where the number is the number of years of service.

(2017-02-14, 07:24 PM)SvePu Wrote: [ -> ]Ok...you're right, but this should work:
<?php
switch($x)
{
  case ($post['regdate']+(60*60*24*30) <= TIME_NOW):
  echo '<div class="postbit-time-1month">1 month on MMH</div>';
  break;
 
  case ($post['regdate']+(60*60*24*62) <= TIME_NOW):
  echo '<div class="postbit-time-2month">2 months on MMH</div>';
  break;
  
  case ($post['regdate']+(60*60*24*182) <= TIME_NOW):
  echo '<div class="postbit-time-halfyear">1/2 year on MMH</div>';
  break;
  
  case ($post['regdate']+(60*60*24*365) <= TIME_NOW):
  echo '<div class="postbit-time-year">1 year on MMH</div>';
  break;
 
  default:
  echo '';
  break;
}
echo $x;
?>



Thanks for the post. a good guide to customize Big Grin

+1.
Cool
(2017-09-09, 08:06 PM)Livewire Wrote: [ -> ]How can you remove 0 years of service lol?

.service-0 {
display: none;
}
Pages: 1 2 3