News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Total time logged in?

Started by RealCop1993, June 09, 2014, 11:29:48 PM

Previous topic - Next topic

RealCop1993

Hello i made some dynamic signatures for my SMF forum.
So the thing is, when i get the row from datebase as ''['total_time_logged_in']'' the time will display in minutes but i want to show it in string as example: 01d 30h 19s
I tryed to find solution before i requested help but no success so i went to ask here...

So i do it like this now


<?php
$totaltime 
$row['total_time_logged_in'];

imagettftext($Signature200325129$COLOR_GRAY$FONT_SOME$totaltime);
?>



and the result is:




Regards,
RC

"Wanting to believe the best about people doesn't make it true."

– Dr. House

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

RealCop1993

I knew for this way it's like im using in themes the code i put in index.template.
But that's won't work since signature.php is just reading infos from datebase it's not part of SMF system you just put php where is SSI and thats all. I need another way so i can convert time directly in the file no't via smf variable

"Wanting to believe the best about people doesn't make it true."

– Dr. House

margarett

It should be the same... You get the value from the database like you did, then you apply this:


// Figure out how long they've been logged in.
$context['members'][$member]['time_online'] = array(
'days' => floor($context['members'][$member]['total_time_logged_in'] / 86400),
'hours' => floor(($context['members'][$member]['total_time_logged_in'] % 86400) / 3600),
'minutes' => floor(($context['members'][$member]['total_time_logged_in'] % 3600) / 60),
);

(of course, you will not call it $context[yabadabadaba], but anything else)
That will calculate you days, hours, minutes. Then you just need to add that those values your script ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: