Home » PHP

PHP Code to print current time in various formats

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

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




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.