Grouping posts by date

<?php 
$day_check = '';
while (have_posts()) : the_post(); 
  $day = get_the_date('j');
  if ($day != $day_check) {
    if ($day_check != '') {
      echo '</ul>'; // close the list here
    }
    echo get_the_date() . '<ul>';
  }
?>
<li><a href="#"><?php the_time(); ?><?php the_title(); ?></a></li>
<?php 
$day_check = $day;
endwhile; ?>

do like this i hop this work

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)