ExamVeda
Login
Home
11
How many methods does the DateTime class have?
Discuss
Answer & Solution
Answer: Option B
Solution:
The DateTime class has nine methods, all of which are public.
12
How many constants does the DateTime class have?
Discuss
Answer & Solution
Answer: Option D
Solution:
The DateTime class has 11 constants, no static properties or methods.
13
Which method is simply an object-oriented version of date()?
Discuss
Answer & Solution
Answer: Option A
Solution:
The format() method is simply an object-oriented version of date(). It takes $dateFormat as an argument. $dateFormat is a string consisting of the same date formatting characters accepted by the procedural date() function.
14
Which of the following is the right way to use the DateTime class?
Discuss
Answer & Solution
Answer: Option C
Solution:
The way you use the DateTime class is like any other class: instantiate an object, and store it in a variable.
15
What will be the output of the following PHP code if date is 24/02/2008?
<?php
$date = new DateTime();
echo $date->format('l,F,js,Y')
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
The format() method displays the date in same way as standard date function().
16
Which of the following statements can be used to set the time zone in individual scripts?
Discuss
Answer & Solution
Answer: Option B
Solution:
You can also use ini_set(‘date.timezone’, ‘Europe/London’);.
17
Among the four PHP DateTimeZone classes given below how many are static? 1. listAbbreviations() 2. getName() 3. getOffset() 4. listIdentifiers()
Discuss
Answer & Solution
Answer: Option B
Solution:
listAbbreviations() and listIdentifiers() are static methods.
18
Among the four PHP DateTimeZone classes given below how many are nonstatic? 1. _construct() 2. getName() 3. getOffset() 4. getTransitions()
Discuss
Answer & Solution
Answer: Option D
Solution:
All of the given methods are non static.
19
Which of the following statements can be used to add two months to the existing date?
Discuss
Answer & Solution
Answer: Option A
Solution:
To change the date stored by a DateTime object after it has been created, you use DateTime::modify() with a natural language expression.
20
Which method enables you to calculate whether daylight saving time is in force at a specific date and time?
Discuss
Answer & Solution
Answer: Option B
Solution:
This outputs a multidimensional array listing past and future changes to the offset from UTC for a DateTimeZone object.