TAV1702 Posted April 19, 2011 Report 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
Nuclear Posted April 19, 2011 Report 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
flyalaska Posted April 19, 2011 Report Posted April 19, 2011 I think it will show 1969 until they fly their first flight. Quote
Tom Posted April 19, 2011 Report 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
Administrators Nabeel Posted April 19, 2011 Administrators Report Posted April 19, 2011 Are the values populated in the table? Quote
Moderators mark1million Posted April 19, 2011 Moderators Report 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
CPC900 Posted April 19, 2011 Report 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
TAV1702 Posted April 19, 2011 Author Report 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
TAV1702 Posted April 20, 2011 Author Report Posted April 20, 2011 On 4/19/2011 at 6:20 PM, mark1million said: 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
TAV1702 Posted April 20, 2011 Author Report 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
Moderators mark1million Posted April 20, 2011 Moderators Report 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
TAV1702 Posted April 20, 2011 Author Report 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
Administrators Nabeel Posted April 20, 2011 Administrators Report 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
TAV1702 Posted April 20, 2011 Author Report 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
Jeff Posted April 20, 2011 Report 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
Tom Posted April 20, 2011 Report Posted April 20, 2011 On 4/20/2011 at 8:26 PM, Jeff said: 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
TAV1702 Posted April 21, 2011 Author Report 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
Jeff Posted April 21, 2011 Report Posted April 21, 2011 Maybe I read the posts wrong then because I was using it in the pilots_list.tpl. Quote
Tom Posted April 21, 2011 Report Posted April 21, 2011 On 4/21/2011 at 2:52 PM, Jeff said: 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
Txmmy83 Posted March 22, 2013 Report 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
DarlanFernandes Posted April 16, 2020 Report Posted April 16, 2020 Try This <?php echo date(DATE_FORMAT, strtotime($userinfo->joindate)); ?> Quote
DarlanFernandes Posted April 16, 2020 Report Posted April 16, 2020 On 3/22/2013 at 12:16 AM, 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? Expand <?php echo date(DATE_FORMAT, strtotime($pilot->lastpirep)); ?> Quote
Administrators ProAvia Posted April 16, 2020 Administrators Report Posted April 16, 2020 On 4/16/2020 at 6:54 PM, DarlanFernandes said: <?php echo date(DATE_FORMAT, strtotime($pilot->lastpirep)); ?> Expand Be sure that any quoted text will appear in English. 1 Quote
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.