1.

Which of the following statements can be used to add two months to the existing date?(a) $date->modify(‘+2 months’);(b) $date = modify(‘+2 months’);(c) $date = modify(‘2+ months’);(d) $date->modify(‘2+ months’);I have been asked this question in a national level competition.Query is from Working with Dates in division File and Session Handling in PHP of PHP

Answer»

Right choice is (a) $date->MODIFY(‘+2 months’);

The explanation is: To change the date stored by a DATETIME object after it has been created, you USE DateTime::modify() with a natural language EXPRESSION.



Discussion

No Comment Found

Related InterviewSolutions