Q:

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

belongs to collection: PHP Basic Programs

0

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

All Answers

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

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

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

total answers (1)

PHP code to get total number of days in a month... >>
<< PHP Code to print current time in various formats...