Pilot Joined and Last Login Date

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?

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’.

I think it will show 1969 until they fly their first flight.

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>
1 Like

Are the values populated in the table?

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>
1 Like

This is how my pilots list shows up:

http://www.canadianclassicairlines.com/CPC/index.php/pilots

Is that what you want? I can add the code to the forum, once I get home around 10pm EST, if you want!?

Yeah I took the code right out of the pilot details.tpl file. It works fine in the admin section, but not in the profile of pilot center.

I got this to work once in my pilot roster, just not sure how.

This is what i use,

  • Join Date: <?php echo $userinfo->joindate?>
  • Last Visit: <?php echo $userinfo->lastlogin?>
  • Last Flight: <?php echo $userinfo->lastpirep?>
  • 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.

    Ahhhh fudge! It is coming right out of the database. Now I am up a creek without a paddle I think eh?

    Read my post?

    You can easily do an if else, same way as teh pilot list displays No data yes of they have not filed a pirep or the date is 1969 etc, not got round to that yet myself

    Hey Mark, give Tom’s method a try. It works.

    Hi Tom. I did read your post but I thought there was a typo in it is why I did not try it at first. It actually works exactly how I was wanting it to work. Thanks! +1

    DATE_FORMAT is a setting, set in the phpvms_settings table… which is set in the admin panel under site setting

    Nice one Nabeel. I forgot all about that setting. I got it all up to snuff now and working real nice like.

    When I use Tom’s code(s) all my members dates are all 1969 (everyone has logged in and flown before, so not sure what is wrong.

    When I use Tom’s code(s) all my members dates are all 1969 (everyone has logged in and flown before, so not sure what is wrong.

    Where are you using it?

    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.

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

    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>