How to Get Yesterday Records in PHP MySQL?

Feb 14, 2022 . Admin

Hello Friends,

I am going to explain you example of how to get yesterday records in PHP?. You will learn get yesterday records in PHP. I would like get yesterday records in PHP query result.

We will use get search get yesterday records in PHP. You can understand a concept of find yesterday date in PHP. So, we can find yesterday's date in PHP example.

Here i will give you many example find yesterday's in PHP.

Table: users

So, let's see bellow solution:


$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) = SUBDATE(CURDATE(),1)";

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

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

    [id] => 1
    [name] => Nikhil Thumar
    [email] =>
    [created_at] => 2022-02-13 10:19:31
    [updated_at] => 2022-02-11 10:21:30

It will help you...