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

The following PHP topics are used in the above examples:

PHP Basic Programs »



All PHP Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.