Home » PHP

PHP Code to print current date in various formats

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

Source Code and Output to get and print Current Date

<?php
	/*print date in dd/mm/yy format*/
	print "Current date in dd/mm/yy format: " .date("d/m/y");
	print "</br>";
	
	/*print date in dd/mm/yyyy format*/
	print "Current date in dd/mm/yyyy format: " .date("d/m/Y");
	print "</br>";			

	/*print date in dd MON yyyy format*/
	print "Current date in dd MON yyyy format: " .date("d M Y");
	print "</br>";						
	
	/*print date in Day, dd MON yyyy format*/
	print "Current date in Day, dd MON yyyy format: " .date("D, d M Y");
	print "</br>";			
	
	/*print date in Day, dd MONTH yyyy format*/
	print "Current date in Day, dd MONTH yyyy format: " .date("D, d F Y");
	print "</br>";									

?>

Output

Current date in dd/mm/yy format: 08/11/16
Current date in dd/mm/yyyy format: 08/11/2016
Current date in dd MON yyyy format: 08 Nov 2016
Current date in Day, dd MON yyyy format: Tue, 08 Nov 2016
Current date in Day, dd MONTH yyyy format: Tue, 08 November 2016




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.