J'aimerai afficher la date et l'heure dans ce script qui affiche les derniers messages de mon forum mais je ne sais pas comment:
- Code: Tout sélectionner
<?php
function getBrolLastPosts2($itemMax, $titleMaxChar)
{
if (!defined("IN_PHPBB"))
{
define("IN_PHPBB", true);
}
$hiddenForums='2,3,4,5,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,30,31';//exemple, ne pas afficher les forums 2 8 ni 5
$phpbb_root_path = "forum/";
include_once ($phpbb_root_path . "config.php");
include_once ($phpbb_root_path . 'includes/constants.php');
$sql = 'SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_last_post_id, f.forum_id, f.forum_name, p.post_time, u.user_id, u.username';
$sql .=' FROM '.TOPICS_TABLE.' AS t, '.FORUMS_TABLE.' AS f, '.POSTS_TABLE.' AS p, '.USERS_TABLE.' AS u';
$sql .=' WHERE t.forum_id = f.forum_id';
$sql .=' AND t.topic_moved_id = 0 ';
$sql .=' AND p.post_id = t.topic_last_post_id ';
$sql .=' AND u.user_id = p.poster_id';
$sql .=' AND f.forum_id NOT IN('.$hiddenForums.') ';
$sql .=' ORDER BY t.topic_last_post_id DESC LIMIT ' .$itemMax;
$dbConnection=mysql_connect($dbhost, $dbuser, $dbpasswd) or die ("connexion impossible");
mysql_select_db ($dbname) or die ("impossible de sélectionner la db");
mysql_query("SET NAMES 'utf8'");
$result=mysql_query($sql);
if(empty($result))
{
$disp.='<p>Données indisponibles</p>';
}
else
{
while(($obj=@mysql_fetch_object($result))){
$title=$obj->topic_title;
$disp.='<BR /> <img src="forum/styles/prosilver/imageset/icon_topic_newest.gif"> <a href=\''.$phpbb_root_path.'viewtopic.php?p='.$obj->topic_last_post_id.'#'.$obj->topic_last_post_id.'\' ';
$disp.='title=\'Lire le message\'>'.substr($title,0,$titleMaxChar).'</a> <BR />';
$authorDisp=($obj->username!='Anonymous')?$obj->username:'un invité';
$disp.='Astuce posté à '.strftime('%H:%M',$obj->post_time).' par ';
$disp.=($obj->username!='Anonymous')?$obj->username:'un invité ';
}
}
if(isset($dbConnection))
{
mysql_close($dbConnection);
}
return $disp.'<p><a href="forum/trucs-et-astuces-pour-windows-7-f44.html">Voir plus de trucs et astuces ...</a></p>';
}
echo getBrolLastPosts2(6,90);//modifier ces valeurs : ici cela signifie les 20 derniers messages, et 40 caractères maximum
?>
Merci!