Custom Dates

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Custom Dates
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
I have a module I am working on that revolves around our Call of Duty clan. I have made a member profile page that in two of the cells I want to display Time in Service (TIS), and Time in Grade (TIG).

TIS is time served from date of enlistment which in the roster_members table is enlistment_dt to todays date or Getdate() and properly formated into something like 1 Year 3 Months.

TIG is time served from last promotion which in the roster_members table is promotion_dt to the current date.

The code to display TIS in my profile page is as follows:

<td width="12%\" align=\"right\">" 
  . "                     <b><font color=\"#660033\">Time in Service:</font></b>" 
  . "                  </td>" 
  . "                  <td width=\"15%\" colspan=\"2\">" 
  . "                     <p class=\"content\">$info[tis]" 
  . "                  </td>"



Displaying TIG is identical to TIS.

Now a thread I had in PHPBuilder was answered and I was given the following code.

$newestDate= strtotime(date("M d, Y"));
$oldestDate= $info[enlistment_dt];
$daysElapsed=round((strtotime($newestDate) - strtotime($oldestDate))/(60*60*24)-1);
$yrsElapsed=floor($daysElapsed/365);
$monthsLeftOver=floor(($daysElapsed-($yrsElapsed*365))/30);
"<HR>Years:".$yrsElapsed." months:".$monthsLeftOver;


I used the following code earlier in my code to gather the enlistment_dt and display it in the profile page but also want to use enlistment_dt when computing the TIS and TIG.

$result = $db->sql_query("SELECT *, date_format(enlistment_dt,'%e %b %Y') as enlistment_dt FROM roster_members WHERE uniqueid ='$uniqueid'");
$info = $db->sql_fetchrow($result);


I am having trouble understanding this and implementing it into my profile page to see if TIS works. This code displays Years:-35 months:9


Back to top Reply with quote
#2   Re: Custom Dates
madman
CZ Moderator
madman has been a member for over 19 year's 19 Year Member
Status: Offline
Joined: Dec 06, 2004
0.00 posts per day
Posts: 21
Points: 1,234
 Yahoo Messenger  
Replace the following code:
$newestDate= strtotime(date("M d, Y"));

Into:
$newestDate= date("j F Y");




_________________
Cheers,
madman
Back to top Reply with quote
#3   re: Custom Dates
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Thanks.

What is the best way to duplicate this and show this

echo "<HR>Years:".$yrsElapsed." months:".$monthsLeftOver;

in my code.

<td width=\"12%\" align=\"right\">"
  . "                     <b><font color=\"#660033\">Time in Service:</font></b>"
  . "                  </td>"
  . "                  <td width=\"15%\" colspan=\"2\">"
  . "                     <p class=\"content\">$info[tis]"
  . "                  </td>"
  . "                  <td width=\"15%\" align=\"right\">"
  . "                     <b><font color=\"#660033\">Time in Grade:</font></b>"
  . "                  </td>"
  . "                  <td width=\"46%\" colspan=\"3\">"
  . "                     <p class=\"content\">$info[tig]"
  . "                  </td>"


For both Time in Service and Time in Grade. I have tried several times for TIS but keep coming up with errors.


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum