Well what you can do is store the date and then change the layout each time the date changes:
while($news = mysql_fetch_array($query)) {
if(empty($date) || $date != date("format", $news['datetime'])){
$date = date("format", $news['datetime']);
//echo/print some html to show new section
}
echo $news['title'];
echo $news['datetime'];
}
This will handle the date comparisons and knowing when to change dates. "format" indicates the kind of date formatting you would like since you can echo/print the $date
.
PHP date
NOTICE: Do not use MySQL_* for it has been deprecated as of PHP 5.5. Use MySQLi_* or PDO instead