Jump to content

Pilot Joined and Last Login Date


TAV1702

Recommended Posts

Hi guys, I have searched but can not find the answer I am looking for.

In the pilot center, I want to add what date the pilot joined and when their last login was.

I added the code as follws:

<li><strong>Date Joined: </strong><?php echo date(DATE_FORMAT, strtotime($pilotinfo->joindate));?></li>
<li><strong>Last Login: </strong><?php echo date(DATE_FORMAT, strtotime($pilotinfo->lastlogin));?></li>

Nut all it shows is 12/31/1969. I know I did get this to work once, but now I don't remember how I did it. can anyone please help?

Link to comment
Share on other sites

In any language I've ever used, manipulating dates, times, datetimes...always is a big pain :)

I'm no expert in PHP, but unless DATE_FORMAT is some PHP constant (which it could be, for all I know) then you need to actually enter the format that you want as a string. The PHP reference for the date function is here.

An example:

<li><strong>Date Joined: </strong><?php echo date('F j', strtotime($pilotinfo->joindate));?></li>

will display the date as 'Month Day' like 'April 19'.

Link to comment
Share on other sites

Your code is correct, however is $pilotinfo the correct variable? You will see 1969 if it returns 0 or null.

When in profile_main.tpl you will want to use $userinfo, like so:

<li><strong>Date Joined: </strong><?php echo date(DATE_FORMAT, strtotime($userinfo->joindate));?></li>
<li><strong>Last Login: </strong><?php echo date(DATE_FORMAT, strtotime($userinfo->lastlogin));?></li>

  • Like 1
Link to comment
Share on other sites

This is what i use,

<li><strong>Join Date:</strong> <?php echo $userinfo->joindate?></li>
    <li><strong>Last Visit:</strong> <?php echo $userinfo->lastlogin?></li>
    <li><strong>Last Flight:</strong> <?php echo $userinfo->lastpirep?></li>

Hi Mark. +1 man. This worked. However, is there any way you can tell me where it pulls this info from? I would like to change the date format to mm/dd/yy and get rid of the times. I really see no need to display the time they joined or the time they last logged in. Only the dates. ;)

Link to comment
Share on other sites

Hi Jeff. I used it ( Tom's code) in my public_profile.tpl and in the profile_main.tpl and it works fine.

I got ninja's on this one but I was going to ask as well where you were placing the code at. Now the code I originally posted, that is exactly what was happening with me too.

Link to comment
Share on other sites

Maybe I read the posts wrong then because I was using it in the pilots_list.tpl.

It's a different variable in pilots_list.tpl:

<li><strong>Date Joined: </strong><?php echo date(DATE_FORMAT, strtotime($pilot->joindate));?></li>
<li><strong>Last Login: </strong><?php echo date(DATE_FORMAT, strtotime($pilot->lastlogin));?></li>

Link to comment
Share on other sites

  • 1 year later...

Tom that code work very well

<li><strong>Last Login: </strong><?php echo date(DATE_FORMAT, strtotime($pilot->lastlogin));?></li>

I have changed it to

<li><strong>Last Pirep: </strong><?php echo date(DATE_FORMAT, strtotime($pilot->lastPirep));?></li>

which also work great but a pilot without Pirep would be shown as 12/31/1969

can that be catched by an else if?

so that if that value is found it echo 00/00/0000 in my case?

Link to comment
Share on other sites

  • 7 years later...
On 21/03/2013 at 21:16, Txmmy83 said:

Tom esse código funciona muito bem

<li> <strong> Último login: </strong> <? php echo date (DATE_FORMAT, strtotime ($ pilot-> lastlogin));?> </li>

Eu mudei para

<li> <strong> Último Pirep: </strong> <? php echo date (DATE_FORMAT, strtotime ($ pilot-> lastPirep ));?> </li>

que também funciona muito bem, mas um piloto sem Pirep seria mostrado como 31/12/1969

isso pode ser pego por um outro se?

de modo que, se esse valor for encontrado, ele ecoará 00/00/0000 no meu caso?

<?php echo date(DATE_FORMAT, strtotime($pilot->lastpirep)); ?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...