1.

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();The question was posed to me by my school principal while I was bunking the class.Query is from Working with Dates topic in chapter File and Session Handling in PHP of PHP

Answer»

Correct choice is (c) $date = new DateTime();

The explanation is: The way you use the DateTime class is like any other class: instantiate an OBJECT, and STORE it in a VARIABLE.



Discussion

No Comment Found

Related InterviewSolutions