TAV1702 Posted April 19, 2011 Report Share Posted April 19, 2011 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? Quote Link to comment Share on other sites More sharing options...
Nuclear Posted April 19, 2011 Report Share Posted April 19, 2011 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'. Quote Link to comment Share on other sites More sharing options...
flyalaska Posted April 19, 2011 Report Share Posted April 19, 2011 I think it will show 1969 until they fly their first flight. Quote Link to comment Share on other sites More sharing options...
Tom Posted April 19, 2011 Report Share Posted April 19, 2011 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 Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 19, 2011 Administrators Report Share Posted April 19, 2011 Are the values populated in the table? Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted April 19, 2011 Moderators Report Share Posted April 19, 2011 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 Quote Link to comment Share on other sites More sharing options...
CPC900 Posted April 19, 2011 Report Share Posted April 19, 2011 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!? Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 19, 2011 Author Report Share Posted April 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 20, 2011 Author Report Share Posted April 20, 2011 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. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 20, 2011 Author Report Share Posted April 20, 2011 Ahhhh fudge! It is coming right out of the database. Now I am up a creek without a paddle I think eh? Quote Link to comment Share on other sites More sharing options...
Tom Posted April 20, 2011 Report Share Posted April 20, 2011 Read my post? Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted April 20, 2011 Moderators Report Share Posted April 20, 2011 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 Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 20, 2011 Author Report Share Posted April 20, 2011 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 Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 20, 2011 Administrators Report Share Posted April 20, 2011 DATE_FORMAT is a setting, set in the phpvms_settings table........ which is set in the admin panel under site setting Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 20, 2011 Author Report Share Posted April 20, 2011 Nice one Nabeel. I forgot all about that setting. I got it all up to snuff now and working real nice like. Quote Link to comment Share on other sites More sharing options...
Jeff Posted April 20, 2011 Report Share Posted April 20, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tom Posted April 20, 2011 Report Share Posted April 20, 2011 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? Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted April 21, 2011 Author Report Share Posted April 21, 2011 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. Quote Link to comment Share on other sites More sharing options...
Jeff Posted April 21, 2011 Report Share Posted April 21, 2011 Maybe I read the posts wrong then because I was using it in the pilots_list.tpl. Quote Link to comment Share on other sites More sharing options...
Tom Posted April 21, 2011 Report Share Posted April 21, 2011 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> Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted March 22, 2013 Report Share Posted March 22, 2013 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? Quote Link to comment Share on other sites More sharing options...
DarlanFernandes Posted April 16, 2020 Report Share Posted April 16, 2020 Try This <?php echo date(DATE_FORMAT, strtotime($userinfo->joindate)); ?> Quote Link to comment Share on other sites More sharing options...
DarlanFernandes Posted April 16, 2020 Report Share Posted April 16, 2020 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)); ?> Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted April 16, 2020 Administrators Report Share Posted April 16, 2020 23 hours ago, DarlanFernandes said: <?php echo date(DATE_FORMAT, strtotime($pilot->lastpirep)); ?> Be sure that any quoted text will appear in English. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.