TinyPortal

Development => Support => Topic started by: Przemek84 on October 07, 2008, 07:21:56 PM

Title: How to change time format in shoutbox only
Post by: Przemek84 on October 07, 2008, 07:21:56 PM
Hi,

I need to change the time format in shoutbox, but not in other places. I've read this topic: http://www.tinyportal.net/index.php/topic,155.0.html but it seems it is a bit outdated because the code is different now. What is more, the solution changes the time format everywhere.

Does anyone have an idea how to do it?

Any hints are welcomed.
Title: Re: How to change time format in shoutbox only
Post by: IchBin on October 07, 2008, 07:36:39 PM
Yes, considering that was 3 years ago. I hope the code has changed. :D I can only assume that you are asking about TP 1.0 beta 1 and also that you are using the simple shoutbox and not the advanced? Please provide us with the details that the posting guidelines ask for. Thanks! (http://www.tinyportal.net/index.php/topic,581)
Title: Re: How to change time format in shoutbox only
Post by: Przemek84 on October 07, 2008, 07:39:32 PM
Quote from: IchBinâ,,¢ on October 07, 2008, 07:36:39 PM
Yes, considering that was 3 years ago. I hope the code has changed. :D I can only assume that you are asking about TP 1.0 beta 1 and also that you are using the simple shoutbox and not the advanced? Please provide us with the details that the posting guidelines ask for. Thanks! (http://www.tinyportal.net/index.php/topic,581)

Hmmm.... have you looked at my signature?
Title: Re: How to change time format in shoutbox only
Post by: IchBin on October 07, 2008, 07:56:41 PM
Quote from: Przemek84 on October 07, 2008, 07:39:32 PM
Quote from: IchBinâ,,¢ on October 07, 2008, 07:36:39 PM
Yes, considering that was 3 years ago. I hope the code has changed. :D I can only assume that you are asking about TP 1.0 beta 1 and also that you are using the simple shoutbox and not the advanced? Please provide us with the details that the posting guidelines ask for. Thanks! (http://www.tinyportal.net/index.php/topic,581)

Hmmm.... have you looked at my signature?
As a matter of fact, no I haven't. lol Thanks for pointing that out. I'll go take a look at the code for you. :D
Title: Re: How to change time format in shoutbox only
Post by: IchBin on October 07, 2008, 08:37:23 PM
Sorry, got distracted at work. HOW DARE THEY! ;)

// don't fetch more than a hundred - save the poor server! :D
if($limit>100) $limit=100;
$request = db_query("SELECT * FROM {$tp_prefix}shoutbox WHERE value7=0 ORDER BY value2 DESC LIMIT $limit", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
$nshouts= $txt['tp-last'].' '.$limit.' '.$txt['tp-shouts'].'<hr />';

while($row = mysql_fetch_assoc($request))
{
$nshouts .='<div style="margin: 4px;"><div style="border: dotted 1px; padding: 2px 4px 2px 4px;" class="windowbg2"><b>'.$row['value3'].'</b></div><div style="padding: 2px;"> '.timeformat($row['value2']).'</div><div style="padding: 4px;">';
$myshout='';
$myshout=$row['value1'];
$nshouts .= doUBBC(censorText($myshout));
$nshouts .= '</div></div>';
}
$context['TPortal']['shoutbox']=$nshouts;
mysql_free_result($request);


You can see that it uses SMF's timeformate() function. You can change this to use the php date() function and then customize it to the layout of date-month-year that you want.
http://www.php.net/date

So if you wanted the date to appear in this formate mm-dd-yy you would replace timeformate($row['value2']) with this -   date('d-m-y', $row['value2'])

Forgot to say, this is in the TPshout.php file in the Sources folder.
Title: Re: How to change time format in shoutbox only
Post by: Przemek84 on October 07, 2008, 09:02:19 PM
Thanks... everything works fine. One point to clarify: in my version the code is located in Sources/TPortal.php (line 700 more or less)
Title: Re: How to change time format in shoutbox only
Post by: IchBin on October 07, 2008, 10:10:16 PM
Ah yes, that would be before it was moved to the modules. :) TP 1.x beta