In: Computer Science
Use what you learned in Chapter 19 to display the following date and time using php:
Today is Tuesday October 6th.
The current time is 14:07:29 PM PDT.
Your display should appear exactly has displayed on separate lines. The date should be displayed using one function from the chapter and the time another.
Following is the code of Formatted Date in PHP::
<?php
// Date formatting in PHP
date_default_timezone_set('America/Los_Angeles');//changing default timezone to PDT
echo "Today is " .date("l F jS.");
echo "\n"; //New-Line Charector
echo "The current time is ".date("H:i:s A T.");
?>
: : The screenshot of output : :
NOTE:
format charecter | Description |
l | A full textual representation of the day of the week such as Sunday ,Monday |
F | A full textual representation of a month, such as January or March |
j | Day of the month without leading zeros |
S | Suffix of day of month ,2 charecters ,example- st,nd,rd or th |
H | Hour in 24-hour format ,with leading zeroes |
i | Minutes with leading zeroes |
s | Seconds with leading zeros |
A | AM or PM (in uppercase) |
T | Timezone abbreviation , Example:EST,MDT,PDT... |
Above is the complete description of Format charecters used in the code in date() function.
*Please rate this answer. Your feedback is important to us.