Web Designing MCQs

Top 20 MCQ Questions on Handling Date and Time in PHP

Pinterest LinkedIn Tumblr

Here are the collections of top 20 MCQ questions on handling date and time in PHP includes the multiple-choice questions on PHP’s date and time library. It includes objective type questions on validating dates, formatting dates and times, converting a timestamp to user-friendly values, creating a timestamp based on specific date and time, displaying the localized date and time, and displaying the web page’s most recent modification date.

Read Also: Top 20 MCQ Questions on Handling Files in PHP

1) Which of the following are the valid format parameters of the date() function.
i. A ii. D
iii. K iv. G
A. i, ii and iii only
B. ii, iii and iv only
C. i, ii and iv only
D. All i, ii, iii and iv

2) State whether the following statements about the date() function’s format parameters are TRUE or FALSE.
i. Parameter m specifies the numeric representation of the month with zeros.
ii. Parameter n specifies the numeric representation of the month without zeros.
A. i-True, ii-False
B. i-False, ii-True
C. i-False, ii-False
D. i-True, ii-True

3) The … function returns an associative array consisting of elements regarding the current time.
A. getdate()
B. gettimeofday()
C. gettime()
D. gettimeofdate()

4) The … function accepts a timestamp and returns an associative array consisting of it’s components.
A. getdate()
B. gettimeofday()
C. gettime()
D. gettimeofdate()

5) State whether the following statements about the functions for working with timestamps are TRUE or FALSE.
i. The time function is useful for retrieving the preset UNIX timestamp.
ii. The mktime() function is useful for producing a timestamp based on a given date and time.
A. i-True, ii-False
B. i-False, ii-True
C. i-False, ii-False
D. i-True, ii-True

6) The … function formats a date and time according to the localization setting as specified by setlocale().
A. setflocale()
B. strtime()
C. strftime()
D. localtime()

7) The format parameter of the strftime() function which specifies the numerical day of the month with no leading zero.
A. %e
B. %d
C. %D
D. %g

8) … is the format parameter of the strftime() function which specifies the 12-hour hour format with space preceding single-digit hours.
A. %h
B. %l
C. %I
D. %H

9) The … function changes PHP’s localization default by assigning a new value.
A. setflocale()
B. setlocale()
C. mklocale()
D. localtime()

10) In the … function, if no date and time are provided, the timestamp for the current date and time is required.
A. mkdatetime()
B. mkdate()
C. mktime()
D. currenttimestamp()

11) In total … array elements are returned while converting a timestamp to user-friendly values using the getdate() function.
A. 10
B. 11
C. 12
D. 13

12) State whether the following statements about the array elements returned by getdate() function are TRUE or FALSE.
i. ‘mon’ is the numeric representation of the month.
ii. ‘month’ is the text representation of the month.
iii. ‘yday’ is the text representation of the day of the year.
A. i-True, ii-False, iii-True
B. i-False, ii-True, iii-False
C. i-False, ii-False, iii-True
D. i-True, ii-True, iii-False

13) The … function accomplishes the task of validating dates, returning TRUE if the supplied date is valid and FALSE otherwise.
A. date()
B. checkdate()
C. validatedate()
D. chkdate()

14) The … function returns a string representation of the current date and/or time formatted according to the instructions specified by a predefined format.
A. date()
B. strdate()
C. currentdate()
D. stringdate()

15) … is the function parameter of the strtime() function that specifies the numerical week number where the first Sunday of the year is the first day of the first week of the year.
A. %U
B. %V
C. %u
D. %W

16) … is the function parameter of the strftime() function that specifies the numerical week number, where the first Monday is the first day of the first week.
A. %U
B. %V
C. %u
D. %W

17) The … function returns the value of the page’s last modified header or FALSE in the case of an error.
A. lastmod()
B. getlastmod()
C. getmod()
D. getheader()

18) The … method sets the date objects day, month, and year returning TRUE on success and FALSE otherwise.
A. date()
B. setDate()
C. setDateObjects()
D. dateObjects()

19) The … method sets the date object’s hour, minute, and optionally the second, returning TRUE on success and FALSE otherwise.
A. setTime()
B. setTimeFormat()
C. setTimeObjects()
D. timeObjects()

20) The … method calculates the number of days between today and the subscription termination date.
A. diffdate()
B. diff()
C. calcdate()
D. calcdiffdate()

Answers:

  1. C. i, ii and iv only
  2. D. i-True, ii-True
  3. B. gettimeofday()
  4. A. getdate()
  5. D. i-True, ii-True
  6. C. strftime()
  7. A. %e
  8. B. %l
  9. B. setlocale()
  10. C. mktime()
  11. B. 11
  12. D. i-True, ii-True, iii-False
  13. B. checkdate()
  14. A. date()
  15. A. %U
  16. D. %W
  17. B. getlastmod()
  18. B. setDate()
  19. A. setTime()
  20. B. diff()
Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.