(PHP) Task 2: Birthdays Write a PHP program called birthdays.php, that creates a
ID: 3918124 • Letter: #
Question
(PHP)
Task 2: Birthdays
Write a PHP program called birthdays.php, that creates a webpage that contains your birthday dates from your birth to your birthday this year(10/19/1997) and what the corresponding day of the week was for each date. The output of your script should be similar to this example:. Also use the PHP manual to look up info on the date function: PHP date. We did not yet talk about this in class, but add this line somewhere near the top of your PHP code:
date_default_timezone_set('America/Los_Angeles');
Make sure that this line is inside the <?php ?> tags.
Task 3: Make a table
Modify the above program so that the dates and the corresponding days of week are printed in a nice table, with the first column being dates and the second column being the days of week.
Task 3: Make a table
Modify the above program so that the dates and the corresponding days of week are printed in a nice table, with the first column being dates and the second column being the days of week.
Explanation / Answer
ANS 1:
<?php
$birthday = new DateTime('19.10.1997');
$today = new Datetime(date('m.d.y'));
$diff = $today->diff($birthday);
date_default_timezone_set("America/New_York");
echo "The time is " . date("h:i:sa");
printf(' Your age : %d years, %d month, %d days', $diff->y, $diff->m, $diff->d);
printf(" ");
?>
Ans2.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.