How to Get Today's Records in PHP MySQL?

Feb 12, 2022 . Admin

Hello Friends,

I am going to explain you example of how to get today's records in PHP?. You will learn get today's records PHP server. I would like to PHP select records with today's date. This article will give you simple example of get today records in PHP query.

We will use PHP query to find today records. You can understand a PHP query to get today's records.

Here i will give you many example find today record in PHP.

Table: users


So, let's see bellow solution:

index.php
<?php

$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "db_php";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

$sql = "SELECT 
            * 
        FROM `users` 
        WHERE DATE(created_at) = CURDATE()";

$result = $conn->query($sql);

while ($row = $result->fetch_assoc()) {
    echo '<pre>';
    print_r($row);
}

?>
Output:
Array
(
    [id] => 2
    [name] => Aatman Infotech
    [email] => aatmaninfotech@gmail.com
    [created_at] => 2022-02-12 13:33:52.000000
    [updated_at] => 2020-09-30 13:33:52.000000
)

It will help you...
#PHP