Q:

PHP Code to print current time in various formats

belongs to collection: PHP Basic Programs

0

In this PHP code, we will learn how to get current time and print the time in various different formats?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Source Code and Output to get and print Current Time

<?php
/*print time in HH:MM:SS*/
print "Current time in HH:MM:SS format: " . date("h:i:s");
print "</br>";

/*print time in HH:MM:SS*/
print "Current time in HH:MM:SS am/pm format: " . date("h:i:s a");
print "</br>";

/*print time in HH:MM:SS*/
print "Current time in HH:MM:SS AM/PM format: " . date("h:i:s A");
print "</br>";

/*print time in HH:MM:SS*/
print "Current time in HH24:MM:SS format: " . date("H:i:s A");
print "</br>";
?>

Output

Current time in HH:MM:SS format: 02:29:27
Current time in HH:MM:SS am/pm format: 02:29:27 pm
Current time in HH:MM:SS AM/PM format: 02:29:27 PM
Current time in HH24:MM:SS format: 14:29:27 PM

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP code to assign and print the current date time... >>
<< PHP Code to print current date in various formats...