TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 790
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

Article Creation Date in Block errors

Started by DonaldDasher, October 24, 2008, 02:48:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DonaldDasher

Can anybody help - most articles have the same date as the creation date in th list but it's correct on the actual articles.

Here's the block codes:

global $db_prefix, $scripturl, $user_info;

$query = db_query(
    "SELECT subject, id, date, shortname
     FROM {$db_prefix}tp_articles
     WHERE approved = 1
     ORDER BY date DESC
     LIMIT 20", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
{
  if(empty($row['shortname'])) $row['shortname'] = $row['id'];

echo '<font size="1pt"><b><a href="' . $scripturl . '?page=' . $row['shortname'] . '">' . $row['subject'] . '</a></b><br>- '. date("M n, Y - g:ia", $row['date']) . '</font><br />';
}


http://www.pre-cert.co.uk/

Ianedres

There is only one date field in 0.98 articles; the SQL query *should* be ordering the results as such (numerically so that the highest timestamp appears first in your list) but I see on your site it is not...

DonaldDasher


JPDeni

You have a problem in your date function:


date("M n, Y - g:ia", $row['date'])


n is the code for the umeric representation of a month, without leading zeros. So, for articles created in October, it will always print out "Oct 10" and for articles created in September, it will always print out "Sep 9." You need to change it to


date("M j, Y - g:ia", $row['date'])


All of the formatting options are given here.

DonaldDasher

Fabulous - much appreciated. All is now working.  ;)

Ianedres

Thanks JPD. Couldn't see the trees for the forest type of thing there...

JPDeni

Happens to me all the time. That's the advantage of having a number of people available to look at things.

This website is proudly hosted on Crocweb Cloud Website Hosting.