Explore topic-wise MCQs in Php.

This section includes 13 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

Which method enables you to calculate whether daylight saving time is in force at a specific date and time?

A. getOffset()
B. getTranitions()
C. ISODate()
D. savingTime()
Answer» C. ISODate()
2.

Which of the following statements can be used to add two months to the existing date?

A. $date->modify(‘+2 months’);
B. $date = modify(‘+2 months’);
C. $date = modify(‘2+ months’);
D. $date->modify(‘2+ months’);
Answer» B. $date = modify(‘+2 months’);
3.

Which of the following DateTimeZone classes are non-static?

A. Only i)
B. Only ii)
C. i), ii), iii) and iv)
D. iii) and iv)View Answer
Answer» D. iii) and iv)View Answer
4.

Which of the following DateTimeZone classes are static?

A. Only i)
B. Only ii)
C. i) and iv)
D. iii) and iv)View Answer
Answer» D. iii) and iv)View Answer
5.

Which of the following statements can be used to set the time zone in individual scripts?

A. date_set_timezone(‘Europe/London’);
B. date_default_timezone_set(‘Europe/London’);
C. date_set_default_timezone(‘Europe/London’);
D. date_default_timezone(‘Europe/London’);
Answer» C. date_set_default_timezone(‘Europe/London’);
6.

What will be the output of the following PHP code if date is 24/02/2008?

A. Sunday, February 24th 2008
B. Sunday, 02 24 2008
C. Sunday, 24 02 2008
D. Sunday, 24th February 2008View Answer
Answer» B. Sunday, 02 24 2008
7.

Which of the following is the right way to use the DateTime class?

A. $date = get_Class(DateTime);
B. $date = class DateTime;
C. $date = new DateTime();
D. $date = new class DateTime();
E. ;b) $date = class DateTime;c) $date = new DateTime();d) $date = new class DateTime();
Answer» D. $date = new class DateTime();
8.

Which method is simply an object-oriented version of date()?

A. DateTime::format()
B. DateTime::modify()
C. DateTime::setTime()
D. DateTime::setDate()
Answer» B. DateTime::modify()
9.

How many constants does the DateTime class have?

A. 8
B. 9
C. 10
D. 11
Answer» E.
10.

How many methods does the DateTime class have?

A. 8
B. 9
C. 10
D. 11
Answer» C. 10
11.

WHICH_OF_THE_FOLLOWING_STATEMENTS_CAN_BE_USED_TO_ADD_TWO_MONTHS_TO_THE_EXISTING_DATE??$

A. $date->modify(‘+2 months’);
B. $date = modify(‘+2 months’);
C. $date = modify(‘2+ months’);
D. $date->modify(‘2+ months’);
Answer» C. $date = modify(‚Äö√Ñ√∂‚àö√ë‚àö‚â§2+ months‚Äö√Ñ√∂‚àö√ë‚àö¬•);
12.

Among the four PHP DateTimeZone classes given below how many are static?

A. listAbbreviations()
B. getName()
C. getOffset()
D. listIdentifiers()
Answer» E.
13.

Sunday, February 24th 2008

A. Sunday, 02 24 2008
B. Sunday, 24 02 2008
C. Sunday, 24th February 2008
Answer» C. Sunday, 24th February 2008