Vidyalelo
PHP · Q14

Date And Timestamp

Programming · PHP · question 14

Q14

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();
Answer
D.
$date = new class DateTime();

Answer: Option C

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.