Skip to main content

Practical-02

Write a PHP program to display the today's date and current time.​

Introduction​

How to display the today's date and current time with PHP programming. The program utilizes the most basic functions of PHP to output the current date and time.

Code​

<?php

// To display the current date
echo "Today's Date is: " . date("d/m/Y") . "<br/>";

// To display the current Time
echo "Current Time is: " . date("h:i:sa");
?>

Output​

Today's Date is: <current date>
Current Time is: <current time>

Explanation​

The program uses the PHP predefined date() function to output the current date and time. The date() function takes the current date and time format as the input.