About
In this code snippet, we’ll learn about the date() function in PHP.
The date() function takes in a string that specifies the date/time format and gives you the result.
Let’s see the example code below.
Code:
<?php //Get current date as day / month / year. echo "Current date: " . date("j/n/Y"); echo "<br>"; //Get current time as hours : minutes : seconds. echo "Current time: " . date("h:i:sa"); echo "<br>"; //Get current date and time as day month(as short string) , year, hours : minutes (12h am/pm). echo "Current time: " . date("j F, Y, g:i a"); echo "<br>";