PHP program to format the date functions in php

Write a PHP program to demonstrate any 5 date functions


In this tutorial, you will learn how to format the date functions in php where we are going to demonstrate with any 5 date functions. So, basically we are formatting the Dates in php.

Below is the php script to format the date functions in php.

<html>
<head>
    <title>PHP Program to Formatting the Date with PHP</title>
</head>
<body>

    <h3>Write a PHP program to demonstrate any 5 date functions</h3>
   
    <?php

        echo "<br>"."Today is".date("y/m/d")."<br>";
        echo "Today is" . date("y:m:d") . "<br>";
        echo "Today is" . date("y-m-d") . "<br>";
        echo "Today is" . date("l") . "<br>"; //Prints the day
        echo "Today is" . date("D") . "<br>"; //Prints the first three letters of a day
        echo "Today is" . date("N") . "<br>"; //Numeric representation of a day

        $date=date_create("2020-10-05");
        date_sub($date,date_interval_create_from_date_string("10 days"));

        echo "The Calculated Date is ".date_format($date,"Y-m-d");

    ?>

</body>
</html>


Thanks for reading.