Jump to content

Recommended Posts

Posted

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?

Posted

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

Posted

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
  • Moderators
Posted

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>

  • Like 1
Posted

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.

Posted

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. ;)

Posted

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

Posted

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. :unsure:

Where are you using it?

Posted

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.

Posted

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>

  • 1 year later...
Posted

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?

  • 7 years later...
Posted
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)); ?>

  • Administrators
Posted
23 hours ago, DarlanFernandes said:

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

Be sure that any quoted text will appear in English.

  • Like 1

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