Breaking News
Home / Training / PHP / The PHP Time Formats With Date

The PHP Time Formats With Date

Display a Simple Time With PHP Date functuion

PHP Time Formats With php Date functions are below some examples
H – 24-hour Display format of a hour (00 to 23)
h – 12-hour Display format of a hour with leading zeros (01 to 12)
i – Display Minutes with zeros (00 to 59)
s – Display Seconds with zeros (00 to 59)
a – Lowercase Ante meridiem and Post meridiem (am or pm)
The example below outputs the current time in the specified format:
please PHP Date

echo "Current time is " . date("h:i:sa");

In this case we are using php date function to display current time.

function displaymyAge(int $mybirthYear):string {

// calculate the age by subtracting the birth year from the current year.

$yearsOld = date('Y') - $mybirthYear;

// return the age in a descriptive string.
return $yearsOld . ' year' . ($yearsOld != 1 ? 's' : '');


echo 'My current age is ' . displaymyAge(1995) . ' old.';

About admin

Leave a Reply

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