Vidyalelo
PHP · Q19

Date And Timestamp

Programming · PHP · question 19

Q19

Which of the following statements can be used to add two months to the existing date?

A.
$date->modify(‘+2 months’);
Answer
B.
$date = modify(‘+2 months’);
C.
$date = modify(‘2+ months’);
D.
$date->modify(‘2+ months’);

Answer: Option A

Solution

Answer: Option A
Solution:
To change the date stored by a DateTime object after it has been created, you use DateTime::modify() with a natural language expression.