1.

To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed?(a) $date = Date(“22 JUNE 2013”)(b) $date = new Date(“JUNE 22 2013”)(c) $date = DateTime(“22 JUNE 2013”)(d) $date = new DateTime(“22 JUNE 2013”)I have been asked this question during an interview for a job.Asked question is from Date and Timestamp topic in chapter File and Session Handling in PHP of PHP

Answer»

Correct OPTION is (d) $date = NEW DateTime(“22 JUNE 2013”)

To elaborate: The dateTime() method is class constructor. You can set the date EITHER at the time of INSTANTIATION or later by using a variety of mutators.



Discussion

No Comment Found

Related InterviewSolutions