murachs_php_4E_chapter10

rtf

School

Southern Illinois University, Carbondale *

*We aren’t endorsed by this school

Course

405

Subject

Computer Science

Date

Nov 24, 2024

Type

rtf

Pages

4

Uploaded by dustinmyers

Report
Chapter 10: How to work with dates Murach's PHP and MySQL (4th Ed.) MULTIPLE CHOICE 1. When you create a DateInterval object, you pass it one argument that specifies one or more of the following: a. years, months, days b. hours, minutes, seconds c. years, months, days, hours, minutes, seconds d. years, months, weeks, days, hours, minutes, seconds ANS: D 2. If $today contains a DateTime object for December 25, 2021, what output would be produced by the code below? echo $today->format('n/j/Y'); a. 12/25/2021 c. Dec. 25, 2021 b. December 25, 2021 d. 12/25/21 ANS: A 3. A/An ______________ is an integer that represents a date and time as the number of seconds since midnight, January 1, 1970. a. timestamp c. date_format b. intdate d. checkdate ANS: A 4. If $today contains a DateTime object for December 25, 2021, what output would be produced by the code below? echo $today-> format('F d, Y'); a. 12/25/2021 c. December 25, 2021 b. Dec. 25, 2021 d. 12/25/21 ANS: C 5. Which of the following is a method of a DateTime object that can be used to determine an amount of time between two dates or times? a. diff() c. datebetween() b. datediff() d. add() ANS: A 6. If $today contains a DateTime object for December 25, 2021, what output would be produced by the code below? echo $today-> format('M. d, Y'); a. 12/25/2021 c. December 25, 2021 b. Dec. 25, 2021 d. 12/25/21 ANS: B
7. To create a DateTime object that represents a due date that’s 90 days after the current date, you use the following code: a. $days = new DateInterval('P90D'); $due_date = date(); $due_date = $due_date->add($days); b. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date->add($days); c. $days = new DateInterval('P90D'); $due_date = date(); $due_date = $due_date + $days; d. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date + $days; ANS: B Code example 10-1 $current_date = new DateTime(); $due_days_diff = $current_date->diff($due_date); if ($current_date > $due_date) { $overdue_message = $due_days_diff->format( '%y years, %m months, and %d days overdue.'); } 8. (Refer to code example 10-1) If $due_date contains a DateTime object, $due_date_diff will contain a. a TimeStamp object b. a DateTime object c. a DateInterval object d. a TimeInterval object ANS: C 9. (Refer to code example 10-1) If $due_date contains a DateTime object for a date that comes 1 month and 7 days before the date stored in the $current_date variable, what will $overdue_message contain when this code finishes executing: a. 0 years, 1 months, and 7 days overdue. b. -0 years, -1 months, and -7 days overdue. c. 1 month and 7 days overdue. d. $overdue_message won’t be set because the if clause won’t be executed ANS: A 10. If $today contains a DateTime object for December 25, 2021, what output would be produced by the code below? echo $today->format('n/d/Y h:i A'); a. 12/25/2021 c. December 25, 2021 b. 12/25/2021 12:00 AM d. 12/25/21 ANS: B 11. If $today contains a DateTime object for December 25, 2021, what output would be produced by the code below? echo $today->format('n/j/y');
a. 12/25/2021 c. December 25, 2021 b. Dec. 25, 2021 d. 12/25/21 ANS: D 12. Timestamps will encounter a/an _______ problem if they are not converted to DateTime objects. a. Y2K c. Y10K b. Y2K38 d. Y69K ANS: B 13. A timestamp stores the number of ________________ since midnight on January 1, 1970 GMT. a. hours c. seconds b. minutes d. microseconds ANS: C 14. Because most systems today store timestamps as 32-bit signed integers, the upper limit of a timestamp on these systems is January 19 in the year________________. a. 2025 c. 2035 b. 2028 d. 2038 ANS: D 15. The use of ________________ objects resolves the Y2K38 problem because the upper limits of dates and times are essentially removed. a. Date c. Time b. DateTime d. DateInterval ANS: B 16. To create a DateTime object for the current date, you use the ________________ keyword and pass no arguments to the constructor. a. date c. new b. now d. create ANS: C 17. To create a DateTime object based on the date and time you specifiy, you use a/an ________________ template. a. absolute c. fixed b. relative d. adjustable ANS: A 18. To create a DateTime object based on an offset you specify to the current date and time, you use a/an ________________ template. a. absolute c. fixed b. relative d. adjustable ANS: B 19. Which of the following functions can you use to modify a DateTime object?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
a. setDate() c. modify() b. setTime() d. all of these ANS: D 20. Which of the following is a method of a DateTime object that can be used to add a period of time to the date? a. addInterval() c. addDate() b. addspan() d. add() ANS: D 21. The diff() method of a DateTime object requires another DateTime object as its argument and returns a/an ________________ object. a. DateTime c. TimeSpan b. DateInterval d. none of these ANS: B