Learn How To Get Yesterday Today Tomorrow Date In PHP

admin_img Posted By Bajarangi soft , Posted On 02-09-2020

get today's, tomorrow's, yesterday's date in php

Get Today Yesterday Tomorrow Date in PHP

First Need to Create PHP File

1. Add The HTML5 Doctype

<!DOCTYPE html>
<html lang="en">
<head>
    <title>DATES</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>

</body>
</html>


2. You Need to Add This Link Inside PHP File
<link rel="stylesheet" href="css/style.css">


3. You Need to Add This PHP code Inside PHP File

 Todays date code

<?php
echo date("Y-m-d");
echo date("l");
?>

Yesterday date code
<?php
$d=strtotime("yesterday");
echo date("Y-m-d", $d);
echo date("l", $d);
?>

Tomorrow date code
<?php
$d=strtotime("tomorrow");
echo date("Y-m-d ", $d);
echo date("l", $d);
?>


4.Create a PHP File
Index.php

<div class="container">
    <div class="col-md-12 mt-5">
        <div class="row">
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body pt-0">
                        <div class="bs_card">
                            <img class="bs_logo" src="b_soft.png">
                        </div>
                        <h3 class="text-center">TODAY'S DATE</h3>
                        <?php
                        echo '<h6 class="text-center">'.date("Y-m-d").'</h6>';
                        echo '<h6 class="text-center">'.date("l").'</h6>';
                        ?>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body pt-0">
                        <div class="bs_card">
                            <img class="bs_logo" src="b_soft.png">
                        </div>
                        <h3 class="text-center">YESTERDAY'S DATE</h3>
                        <?php
                        $d=strtotime("yesterday");
                        echo '<h6 class="text-center">'.date("Y-m-d", $d).'</h6>';
                        echo '<h6 class="text-center">'.date("l",$d).'</h6>';
                        ?>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body pt-0">
                        <div class="bs_card">
                            <img class="bs_logo" src="b_soft.png">
                        </div>
                        <h3 class="text-center">TOMORROW'S DATE</h3>
                        <?php
                        $d=strtotime("tomorrow");
                        echo '<h6 class="text-center">'.date("Y-m-d ", $d).'</h6>';
                        echo '<h6 class="text-center">'.date("l",$d).'</h6>';
                        ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

5.Create a CSS File, Inside Your CSS Folder
style.css
body{
    background: black;
}
.bs_logo{
    width: 180px;
    height: 125px;
}
.bs_card{
    display: flex;
    align-items: center;
    justify-content: center;
}
.bs_label{
    font-weight: bold;
}
.bs_submit_btn{
    padding: 5px 20px;
    border-radius: 20px;
}
.bs_logo_img{
    width: 50px;
    height: 50px;
}


6.Complete Code Of PHP File
<!DOCTYPE html>
<html lang="en">
<head>
    <title>DATES</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
    <div class="col-md-12 mt-5">
        <div class="row">
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body pt-0">
                        <div class="bs_card">
                            <img class="bs_logo" src="b_soft.png">
                        </div>
                        <h3 class="text-center">TODAYS DATE</h3>
                        <?php
                        echo '<h6 class="text-center">'.date("Y-m-d").'</h6>';
                        echo '<h6 class="text-center">'.date("l").'</h6>';
                        ?>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body pt-0">
                        <div class="bs_card">
                            <img class="bs_logo" src="css/b_soft.png">
                        </div>
                        <h3 class="text-center">YESTERDAY DATE</h3>
                        <?php
                        $d=strtotime("yesterday");
                        echo '<h6 class="text-center">'.date("Y-m-d", $d).'</h6>';
                        echo '<h6 class="text-center">'.date("l",$d).'</h6>';
                        ?>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body pt-0">
                        <div class="bs_card">
                            <img class="bs_logo" src="css/b_soft.png">
                        </div>
                        <h3 class="text-center">TOMORROW'S DATE</h3>
                        <?php
                        $d=strtotime("tomorrow");
                        echo '<h6 class="text-center">'.date("Y-m-d ", $d).'</h6>';
                        echo '<h6 class="text-center">'.date("l",$d).'</h6>';
                        ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>

Related Post