Home » PHP

PHP code to assign and print the current date time in variables

In this PHP code, we will learn how to get and assign current date time into variables and print them on the webpage?

Source Code and Output to Get, Assign and print Current Date and Time

<?php
	$cur_date = date("D, d M Y");
	$cur_time = date("h:i:s a");
	
	/*print values of cur_date and cur_time*/
	printf("Current date is: " .$cur_date);
	print "</br>";				
	printf("Current time is: " .$cur_time);
	print "</br>";						
?>

Output

Current date is: Tue, 08 Nov 2016
Current time is: 02:33:48 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.