I have this snippet:
function count_user_comments_today( $uid ){
global $wpdb;
$today = date('Y-m-d');
$tomorrow = date('Y-m-d', time() + 86400);
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_date >= %s AND comment_date < %s ", $uid, $today, $tomorrow ));
return $count;
}
But this get's the comments per day and that for a specific user. I want it to be generic, for the whole site and per hour, per year and per month.... Is this possible? Of course also the posts and not only the comments.