TinyPortal

Development => Support => Topic started by: neoxes on June 29, 2012, 01:13:03 PM

Title: Article timestamp & Shoutbox
Post by: neoxes on June 29, 2012, 01:13:03 PM
Link to my site: http://www.evezine.eu
SMF version: SMF 2.0.2
TP version: TP ver. 1.0
Default Forum Language: Italian
Theme name and version: Curve default

Hi!
Can you help me with this:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi1094.photobucket.com%2Falbums%2Fi455%2Fneoxes%2FCattura-4.png&hash=9c2876e0f474f60bb12343205f35130a4292a10b)

I want the same time format.

Thanks!


Another problem, default shoutbox is not showing shouts in frontpage... I have to click on show last 50 shouts.
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 29, 2012, 04:53:11 PM
Shoutbox fixed adding:

.tp_shoutframe div.hide
{
display: block;
}


in tpshout.css

Tell me if this is correct please.
Title: Re: Article timestamp & Shoutbox
Post by: IchBin on June 29, 2012, 09:28:04 PM
I have no idea what you mean by "shoutbox is not showing shouts in frontpage". It works for me. Perhaps you could show us a screenshot or point us to the site that you are actually using TP on? The link you provided goes to a site where SimplePortal is used.
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 29, 2012, 10:14:29 PM
Quote from: IchBin™ on June 29, 2012, 09:28:04 PM
I have no idea what you mean by "shoutbox is not showing shouts in frontpage". It works for me. Perhaps you could show us a screenshot or point us to the site that you are actually using TP on? The link you provided goes to a site where SimplePortal is used.

Yep, I want to use Tinyportal but i need to fix it first, so I'm "playing" with a local backup where I've installad Tinportal. Here's the problem:

http://i1094.photobucket.com/albums/i455/neoxes/Cattura1.png (http://i1094.photobucket.com/albums/i455/neoxes/Cattura1.png)
http://i1094.photobucket.com/albums/i455/neoxes/Cattura2.png (http://i1094.photobucket.com/albums/i455/neoxes/Cattura2.png)
Firebug:
http://i1094.photobucket.com/albums/i455/neoxes/Cattura3.png (http://i1094.photobucket.com/albums/i455/neoxes/Cattura3.png)

Any help for timestamp problem?
Title: Re: Article timestamp & Shoutbox
Post by: IchBin on June 29, 2012, 10:18:55 PM
Do you have any other mods installed? It looks to me like you have some CSS That is overriding what TP has for the shoutbox, thus hiding your shouts. It's either that or some javascript toggling the visibility some how.

The timestamp I'll have to look at when I get a chance.
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 29, 2012, 10:24:51 PM
edit
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 29, 2012, 10:35:54 PM
Found it! It's tabbed smileys mod.

Here's the code:
https://github.com/emanuele45/Tabbed-Smileys/blob/66c0c5050e720daf43482587a3b51a1d895234a7/modification_SMF2.xml
Title: Re: Article timestamp & Shoutbox
Post by: ZarPrime on June 29, 2012, 11:51:37 PM
On the timestamp thing you mentioned in your first post, a lot of this depends on the Default time format you have set in your Admin General Features and Options and whether you have enabled shorthand date display in your Admin Layout settings, along with the Layout Type you have set for your FrontPage Topics and Articles.

Obviously, it's much easier to figure out what it is going to look like in a few days, when it is no longer either "Today" or "Yesterday".  From the screenshot you included in your first post, it looks like you have military time set but the title bar of the topic or article seems to be defaulting to a 12 hour format that the Layout Type specifies though I'm not sure why the "PM" wouldn't be showing up after the "01:21".  Again, this could depend on the Layout Type for the FrontPage.

If we could see this in person instead of just a screenshot, and if you told us what your Admin settings and the TP Admin settings for the Frontpage layout that I mentioned above, we may be able to tell a little more about it.

ZarPrime
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 30, 2012, 01:33:23 PM
Quote from: ZarPrime on June 29, 2012, 11:51:37 PM
On the timestamp thing you mentioned in your first post, a lot of this depends on the Default time format you have set in your Admin General Features and Options and whether you have enabled shorthand date display in your Admin Layout settings, along with the Layout Type you have set for your FrontPage Topics and Articles.

Obviously, it's much easier to figure out what it is going to look like in a few days, when it is no longer either "Today" or "Yesterday".  From the screenshot you included in your first post, it looks like you have military time set but the title bar of the topic or article seems to be defaulting to a 12 hour format that the Layout Type specifies though I'm not sure why the "PM" wouldn't be showing up after the "01:21".  Again, this could depend on the Layout Type for the FrontPage.

If we could see this in person instead of just a screenshot, and if you told us what your Admin settings and the TP Admin settings for the Frontpage layout that I mentioned above, we may be able to tell a little more about it.

ZarPrime

First of all, thanks for your help!
Concerning your questions:
- Default time format on my website is %d/%m/%Y - %H:%M
- Layout Type for the frontpage is the default one, no edits.

Today's test :

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi1094.photobucket.com%2Falbums%2Fi455%2Fneoxes%2Ftoday.png&hash=6630fa4f0702cdc630bb9e40aac69cb383d6a0b7)

*** ZarPrime Edit:  OK, I modified the post so that the image actually shows instead of just the link. ***

If you need it I can upload the whole site in a temp directory, tell me if this is necessary.
Title: Re: Article timestamp & Shoutbox
Post by: ZarPrime on June 30, 2012, 02:54:38 PM
Quote from: neoxes on June 30, 2012, 01:33:23 PM
- Default time format on my website is %d/%m/%Y - %H:%M

OK, then, the notation is correct, since you are showing "Today" rather than disabling this layout in Admin ...
  %d - day of the month (01 to 31)
  %m - month as a number (01 to 12)
  %Y - 4 digit year
  %H - hour using a 24-hour clock (range 00 to 23)
  %M - minute as a number

Today is June 30th, 2012, so, with your setting (%d/%m/%Y - %H:%M), this would equate to "30/06/2012 - 14:24" which is what it would say if it wasn't "Today", at least for the post itself.  In other words, if it was no longer "Today", it would say "30/06/2012 - 14:24".

As for the titlebar, since it is still "Today", "Today at 02:24 PM" is correct for that layout.  If it was no longer "Today", that would revert to "%d %b %Y" which would be "30 Jun 2012" as that is the default notation for that particular layout.  See the test image that I did below.

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi714.photobucket.com%2Falbums%2Fww142%2FZarPrime%2FLurk-TP-FP-Topics.png&hash=df1585e0197020d8e011ed73752dd852ce2068a5)

I hope that was clear.

ZarPrime
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 30, 2012, 08:29:29 PM
It's clear, but (same example) if I want to display "Today at 14:24" insted of  "Today at 02:24 PM" I should edit tinyportal files? Which one?
Title: Re: Article timestamp & Shoutbox
Post by: ZarPrime on June 30, 2012, 08:43:42 PM
Well, we don't like telling people how to modify TP core code to do stuff like this because, the next time you upgrade your version, it will wipe out your edits but, if you are using SMF 2.0+, look on about line 1554 of the TPsubs.template.php file and find this line ...


<span class="article_shortdate">' . tptimeformat($context['TPortal']['article']['date'], true, '%d %b %Y').' - </span>';

      
See there near the end of that line where you it says '%d %b %Y'?  You might be able to edit that to do what you want.  Make sure you backup the file first before doing this and post back after you have done it to let us know how it went because I'm not certain that this is the only thing that might need to be changed.  Ichbin probably knows for sure but I'm uncertain.

ZarPrime
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on June 30, 2012, 11:26:19 PM
Quote from: ZarPrime on June 30, 2012, 08:43:42 PM
Well, we don't like telling people how to modify TP core code to do stuff like this because, the next time you upgrade your version, it will wipe out your edits but, if you are using SMF 2.0+, look on about line 1554 of the TPsubs.template.php file and find this line ...


<span class="article_shortdate">' . tptimeformat($context['TPortal']['article']['date'], true, '%d %b %Y').' - </span>';

      
See there near the end of that line where you it says '%d %b %Y'?  You might be able to edit that to do what you want.  Make sure you backup the file first before doing this and post back after you have done it to let us know how it went because I'm not certain that this is the only thing that might need to be changed.  Ichbin probably knows for sure but I'm uncertain.

ZarPrime

What about using:

timeformat($context['TPortal']['article']['date'])

instead of:

tptimeformat($context['TPortal']['article']['date'], true, time_format)

or using a variable as time_format?
Title: Re: Article timestamp & Shoutbox
Post by: ZarPrime on July 02, 2012, 11:43:55 AM
Well, I don't know how that would work.  Have you tried it?

ZP
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on July 02, 2012, 11:58:33 AM
Quote from: ZarPrime on July 02, 2012, 11:43:55 AM
Well, I don't know how that would work.  Have you tried it?

ZP

timeformat is the default smf function which uses the time format setted in the admin panel of smf.
For the variable option, I dunno what is the variable used to store time format.

Can you explain me why tinyportal uses a custom function to format time insted of original one? Just a curiosity!
Title: Re: Article timestamp & Shoutbox
Post by: ZarPrime on July 02, 2012, 12:20:51 PM
No, I can't explain that but I'm sure there is a good reason for it.  Either Bloc (the original coder of TinyPortal) or Ichbin (the current coder) would have to answer that.

ZP
Title: Re: Article timestamp & Shoutbox
Post by: IchBin on July 02, 2012, 04:59:08 PM
Try replacing the tptimeformat() function with this and see if it does what you want.


function tptimeformat($log_time, $show_today = true, $format)
{
global $context, $user_info, $txt, $modSettings, $smcFunc;
static $non_twelve_hour;

$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;

// We can't have a negative date (on Windows, at least.)
if ($log_time < 0)
$log_time = 0;

// Today and Yesterday?
if ($modSettings['todayMod'] >= 1 && $show_today === true)
{
// Get the current time.
$nowtime = forum_time();

$then = @getdate($time);
$now = @getdate($nowtime);

// Try to make something of a time format string...
$s = strpos($format, '%S') === false ? '' : ':%S';
if (strpos($format, '%H') === false && strpos($format, '%T') === false)
{
$h = strpos($format, '%l') === false ? '%I' : '%l';
$today_fmt = $h . ':%M' . $s . ' %p';
}
else
$today_fmt = '%H:%M' . $s;

// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . tptimeformat($log_time, $today_fmt, $format);

// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
return $txt['yesterday'] . tptimeformat($log_time, $today_fmt, $format);
}

$str = !is_bool($show_today) ? $show_today : $format;

if (setlocale(LC_TIME, $txt['lang_locale']))
{
if (!isset($non_twelve_hour))
$non_twelve_hour = trim(strftime('%p')) === '';
if ($non_twelve_hour && strpos($str, '%p') !== false)
$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);

foreach (array('%a', '%A', '%b', '%B') as $token)
if (strpos($str, $token) !== false)
$str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? $smcFunc['ucwords'](strftime($token, $time)) : strftime($token, $time), $str);
}
else
{
// Do-it-yourself time localization.  Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
if (strpos($str, $token) !== false)
$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
if (strpos($str, '%p'))
$str = str_replace('%p', (strftime('%H', $time) < 12 ? 'am' : 'pm'), $str);
}

// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);

// Format any other characters..
return strftime($str, $time);
}
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on July 02, 2012, 08:39:24 PM
Uhm, nope:

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi1094.photobucket.com%2Falbums%2Fi455%2Fneoxes%2Ftest2.png&hash=c21a0335703ec016662288675c9c73ee4dc8d9f1)
Title: Re: Article timestamp & Shoutbox
Post by: IchBin on July 02, 2012, 10:35:33 PM
Looking at your site I see simple portal....
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on July 02, 2012, 10:37:15 PM
Quote from: IchBin™ on July 02, 2012, 10:35:33 PM
Looking at your site I see simple portal....

I wrote it: "Yep, I want to use Tinyportal but i need to fix it first, so I'm "playing" with a local backup where I've installad Tinportal."
Title: Re: Article timestamp & Shoutbox
Post by: IchBin on July 03, 2012, 12:28:44 AM
Quote from: neoxes on July 02, 2012, 10:37:15 PM
Quote from: IchBin™ on July 02, 2012, 10:35:33 PM
Looking at your site I see simple portal....

I wrote it: "Yep, I want to use Tinyportal but i need to fix it first, so I'm "playing" with a local backup where I've installad Tinportal."

And now that I read the topic again I see I already asked about that.... lol I thought it was a different topic. I really don't have the time to look at the code right now. I noticed before that Zarprime asked if you tried the smf timeformat() function. If you want the result of it to look like SMF timeformate() you're going to have to change the function calls to do the same thing. Sorry I just don't have the time to figure it all out for you right now.
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on July 03, 2012, 12:36:36 AM
No problem mate! Thanks for your help anyway!  :)
Title: Re: Article timestamp & Shoutbox
Post by: ZarPrime on July 03, 2012, 06:35:16 AM
The only thing I can tell you is to try replacing the entire tptimeformat function with the SMF timeformat function and see if that works for you.

Code (Find in TPsubs.template.php) Select

// Format a time to make it look purdy.
function tptimeformat($log_time, $show_today = true, $format)
{
global $context, $user_info, $txt, $modSettings, $smcFunc;

$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;

// We can't have a negative date (on Windows, at least.)
if ($log_time < 0)
$log_time = 0;

// Today and Yesterday?
if ($modSettings['todayMod'] >= 1 && $show_today === true)
{
// Get the current time.
$nowtime = forum_time();

$then = @getdate($time);
$now = @getdate($nowtime);

// Try to make something of a time format string...
$s = strpos($format, '%S') === false ? '' : ':%S';
if (strpos($format, '%H') === false && strpos($format, '%T') === false)
{
$h = strpos($format, '%l') === false ? '%I' : '%l';
$today_fmt = $h . ':%M' . $s . ' %p';
}
else
$today_fmt = '%H:%M' . $s;

// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . tptimeformat($log_time, $today_fmt, $format);

// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
return $txt['yesterday'] . tptimeformat($log_time, $today_fmt, $format);
}

$str = !is_bool($show_today) ? $show_today : $format;

if (setlocale(LC_TIME, $txt['lang_locale']))
{
foreach (array('%a', '%A', '%b', '%B') as $token)
if (strpos($str, $token) !== false)
$str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? $smcFunc['ucwords'](strftime($token, $time)) : strftime($token, $time), $str);
}
else
{
// Do-it-yourself time localization.  Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
if (strpos($str, $token) !== false)
$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
if (strpos($str, '%p'))
$str = str_replace('%p', (strftime('%H', $time) < 12 ? 'am' : 'pm'), $str);
}

// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);

// Format any other characters..
return strftime($str, $time);
}


Code (and Replace With This) Select

// Format a time to make it look purdy.
function tptimeformat($log_time, $show_today = true, $offset_type = false)
{
global $context, $user_info, $txt, $modSettings, $smcFunc;
static $non_twelve_hour;

// Offset the time.
if (!$offset_type)
$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
// Just the forum offset?
elseif ($offset_type == 'forum')
$time = $log_time + $modSettings['time_offset'] * 3600;
else
$time = $log_time;

// We can't have a negative date (on Windows, at least.)
if ($log_time < 0)
$log_time = 0;

// Today and Yesterday?
if ($modSettings['todayMod'] >= 1 && $show_today === true)
{
// Get the current time.
$nowtime = forum_time();

$then = @getdate($time);
$now = @getdate($nowtime);

// Try to make something of a time format string...
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
{
$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
$today_fmt = $h . ':%M' . $s . ' %p';
}
else
$today_fmt = '%H:%M' . $s;

// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . tptimeformat($log_time, $today_fmt, $offset_type);

// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
return $txt['yesterday'] . tptimeformat($log_time, $today_fmt, $offset_type);
}

$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];

if (setlocale(LC_TIME, $txt['lang_locale']))
{
if (!isset($non_twelve_hour))
$non_twelve_hour = trim(strftime('%p')) === '';
if ($non_twelve_hour && strpos($str, '%p') !== false)
$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);

foreach (array('%a', '%A', '%b', '%B') as $token)
if (strpos($str, $token) !== false)
$str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? $smcFunc['ucwords'](strftime($token, $time)) : strftime($token, $time), $str);
}
else
{
// Do-it-yourself time localization.  Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
if (strpos($str, $token) !== false)
$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);

if (strpos($str, '%p') !== false)
$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
}

// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);

// Format any other characters..
return strftime($str, $time);
}


In addition to that, you need to understand that the TinyPortal article_shortdate function is just that, a shortened version of the date which is used in the titlebar of whatever article/topic you are rendering, without showing the time, unless the current date is either "Today" or "Yesterday".  If that is the case, the time will be displayed as well, according to how it is rendered by the tptimeformat function.  The short date, without the time, is used to save space in the titlebars.  Otherwise, the default is that it will render the date in the titlebar as "%d %b %Y" which would be, for today's date, "02 JUL 2012".  If you want the short date to display the same as the format you have set in SMF Admin (which is "%d/%m/%Y"), you will also have to edit the TinyPortal article_shortdate function as shown below ...

Code (Find in TPsubs.template.php) Select

<span class="article_shortdate">' . tptimeformat($context['TPortal']['article']['date'], true, '%d %b %Y').' - </span>';


Code (Replace With This) Select

<span class="article_shortdate">' . tptimeformat($context['TPortal']['article']['date'], true, '%d/%m/%Y').' - </span>';


If all this doesn't work, I don't know what else to tell you.  Be sure to backup the TPsubs.template.php file before starting on these edits, in case something goes wrong.

For anyone else searching for this, and finding it, be advised that this is only for SMF 2.0 and TinyPortal 1.0 Final.

ZarPrime
Title: Re: Article timestamp & Shoutbox
Post by: neoxes on July 03, 2012, 08:47:51 AM
Quote from: ZarPrime on July 03, 2012, 06:35:16 AM
The only thing I can tell you is to try replacing the entire tptimeformat function with the SMF timeformat function and see if that works for you.

Code (Find in TPsubs.template.php) Select

// Format a time to make it look purdy.
function tptimeformat($log_time, $show_today = true, $format)
{
global $context, $user_info, $txt, $modSettings, $smcFunc;

$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;

// We can't have a negative date (on Windows, at least.)
if ($log_time < 0)
$log_time = 0;

// Today and Yesterday?
if ($modSettings['todayMod'] >= 1 && $show_today === true)
{
// Get the current time.
$nowtime = forum_time();

$then = @getdate($time);
$now = @getdate($nowtime);

// Try to make something of a time format string...
$s = strpos($format, '%S') === false ? '' : ':%S';
if (strpos($format, '%H') === false && strpos($format, '%T') === false)
{
$h = strpos($format, '%l') === false ? '%I' : '%l';
$today_fmt = $h . ':%M' . $s . ' %p';
}
else
$today_fmt = '%H:%M' . $s;

// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . tptimeformat($log_time, $today_fmt, $format);

// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
return $txt['yesterday'] . tptimeformat($log_time, $today_fmt, $format);
}

$str = !is_bool($show_today) ? $show_today : $format;

if (setlocale(LC_TIME, $txt['lang_locale']))
{
foreach (array('%a', '%A', '%b', '%B') as $token)
if (strpos($str, $token) !== false)
$str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? $smcFunc['ucwords'](strftime($token, $time)) : strftime($token, $time), $str);
}
else
{
// Do-it-yourself time localization.  Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
if (strpos($str, $token) !== false)
$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
if (strpos($str, '%p'))
$str = str_replace('%p', (strftime('%H', $time) < 12 ? 'am' : 'pm'), $str);
}

// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);

// Format any other characters..
return strftime($str, $time);
}


Code (and Replace With This) Select

// Format a time to make it look purdy.
function tptimeformat($log_time, $show_today = true, $offset_type = false)
{
global $context, $user_info, $txt, $modSettings, $smcFunc;
static $non_twelve_hour;

// Offset the time.
if (!$offset_type)
$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
// Just the forum offset?
elseif ($offset_type == 'forum')
$time = $log_time + $modSettings['time_offset'] * 3600;
else
$time = $log_time;

// We can't have a negative date (on Windows, at least.)
if ($log_time < 0)
$log_time = 0;

// Today and Yesterday?
if ($modSettings['todayMod'] >= 1 && $show_today === true)
{
// Get the current time.
$nowtime = forum_time();

$then = @getdate($time);
$now = @getdate($nowtime);

// Try to make something of a time format string...
$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
{
$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
$today_fmt = $h . ':%M' . $s . ' %p';
}
else
$today_fmt = '%H:%M' . $s;

// Same day of the year, same year.... Today!
if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . tptimeformat($log_time, $today_fmt, $offset_type);

// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
return $txt['yesterday'] . tptimeformat($log_time, $today_fmt, $offset_type);
}

$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];

if (setlocale(LC_TIME, $txt['lang_locale']))
{
if (!isset($non_twelve_hour))
$non_twelve_hour = trim(strftime('%p')) === '';
if ($non_twelve_hour && strpos($str, '%p') !== false)
$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);

foreach (array('%a', '%A', '%b', '%B') as $token)
if (strpos($str, $token) !== false)
$str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? $smcFunc['ucwords'](strftime($token, $time)) : strftime($token, $time), $str);
}
else
{
// Do-it-yourself time localization.  Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
if (strpos($str, $token) !== false)
$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);

if (strpos($str, '%p') !== false)
$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
}

// Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that.
if ($context['server']['is_windows'] && strpos($str, '%e') !== false)
$str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str);

// Format any other characters..
return strftime($str, $time);
}


In addition to that, you need to understand that the TinyPortal article_shortdate function is just that, a shortened version of the date which is used in the titlebar of whatever article/topic you are rendering, without showing the time, unless the current date is either "Today" or "Yesterday".  If that is the case, the time will be displayed as well, according to how it is rendered by the tptimeformat function.  The short date, without the time, is used to save space in the titlebars.  Otherwise, the default is that it will render the date in the titlebar as "%d %b %Y" which would be, for today's date, "02 JUL 2012".  If you want the short date to display the same as the format you have set in SMF Admin (which is "%d/%m/%Y"), you will also have to edit the TinyPortal article_shortdate function as shown below ...

Code (Find in TPsubs.template.php) Select

<span class="article_shortdate">' . tptimeformat($context['TPortal']['article']['date'], true, '%d %b %Y').' - </span>';


Code (Replace With This) Select

<span class="article_shortdate">' . tptimeformat($context['TPortal']['article']['date'], true, '%d/%m/%Y').' - </span>';


If all this doesn't work, I don't know what else to tell you.  Be sure to backup the TPsubs.template.php file before starting on these edits, in case something goes wrong.

For anyone else searching for this, and finding it, be advised that this is only for SMF 2.0 and TinyPortal 1.0 Final.

ZarPrime

I'll try the first option, but the second works for sure because I already tried it. So thank you!
I'm asking these things as a curiosity, I'm not a coder or a webdevelopper, I'm just an engineer so I'm always interested to understand how things work!  >:D