Home > PHP & Programming > Quizzes > PHP Programming Basics Practice Test: Working with Dates in PHP
PHP Programming Basics Practice Test: Working with Dates in PHP
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Which of the following is the right way to use the DateTime class?”
Quiz on Date and Timestamp & Working with Dates in PHP. PHP has a variety of functions for working with dates and timestamps, including the date() function, which formats a timestamp into a more readable date and time, and the DateTime class, which provides an object-oriented approach to working with dates and times.  The syntax for the date() function is: date(format,timestamp) [1]  The format parameter specifies how to format the date or time, and the timestamp parameter specifies a timestamp. If omitted, the current date and time will be used.  Here are some characters that are... Show more
PHP Programming Basics Practice Test: Working with Dates in PHP
Time left 00:00
20 Questions

1. Which method is simply an object-oriented version of date()?
2. Which of the following DateTimeZone classes are non-static?
i) _construct()
ii) getName()
iii) getOffset()
iv) getTransitions()
3. Which method enables you to calculate whether daylight saving time is in force at a specific date and time?
4. What will be the output of the following PHP code if date is 24/02/2008?
$date = new DateTime();
echo $date->format('l,F,js,Y');
?>
5. To create an object and set the date to JUNE 22, 2023, which one of the following statement should be executed?
6. Which one of the following function is useful for producing a timestamp based on a given date and time?
7. What will be the output of the following PHP code? (If say date is 22/06/2023.)
printf( date("t") );
?>
8. What will be the output of the following code? (If say date is 22/06/2023.)
echo "Today is ".date("F d, Y");
?>
9. Suppose you want to calculate the date 45 days from the present date which one of the following statement will you use?
10. Which of the following is the right way to use the DateTime class?
11. Which function displays the web page’s most recent modification date?
12. Which of the following DateTimeZone classes are static?
i) listAbbreviations()
ii) getName()
iii) getOffset()
iv) listIdentifiers()
13. What will be the output of the following PHP code?
echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');
?>
14. Which of the following statements can be used to set the time zone in individual scripts?
15. The date() function returns ___ representation of the current date and/or time.
16. If the format is F then which one of the following will be returned?
17. Which one of the following format parameter can be used to identify timezone?
18. Which of the following statements can be used to add two months to the existing date?
19. How many constants does the DateTime class have?
20. How many methods does the DateTime class have?