Je recherche l'astuce pour comparer 2 dates; celle d'aujourd'hui avec celle du jour de postage d'un message afin d'afficher
- aujourd'hui (soit $datepost = $now),
hier(soit $datepost = $now - 1),
la date du postage (soit par défaut)
setlocale(LC_TIME, "fr");
$now = time();
$now_year=date('Y',$now);
$now_month=date('m',$now);
$now_day = date('d',$now);
$now_day_1 = $now_day - 1;
$datepost = strftime('%d %m %Y', $lastlist->days);
$datepost_year = date('Y',$datepost);
$datepost_month = date('m',$datepost);
$datepost_day = date('d',$datepost);
Malheureusement, impossible d'aller plus loin car 'echo $datepost_day' me renvoie n'importe quoi !Par la suite, je pense enchaîner avec :
switch ( $datepost ) {
case $now_day:
$dateview = 'Aujourd\'hui'; break;
case $now_day_1:
$dateview = 'Hier'; break;
default :
$dateview = strftime('%a %d %b %Y', $lastlist->days);
}
$heure = date('H\Hi', $lastlist->days);
echo '<td><div align="right">' . $dateview . ' ' . $heure . '</div></td>';
Une idée pour moi ?Merci