PHP Date

Code Snippets Date
Share:

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>";

Resulting Output:

Share:

Leave a Reply

Your email address will not be published. Required fields are marked *

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger