Home » PHP » PHP Date/Time » Question
  1. To create an object and set the date to JULY 28, 2018, which one of the following statement should be executed?
    1. $date = DateTime(“28 JULY 2018”)
    2. $date = new DateTime(“28 JULY 2018”)
    3. $date = Date(“28 JULY 2018”)
    4. $date = new Date(“JULY 28 2018”)
    5. None of these
Correct Option: B

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.



Your comments will be displayed only after manual approval.