nerdexam
Zend

200-550 · Question #222

Given the following DateTime object, which sample will NOT alter the date to the value '2014-02- 15'? $date = new DateTime('2014-03-15');

The correct answer is D. $date->diff(new DateInterval('-P1M')). See the full explanation below for the reasoning.

Question

Given the following DateTime object, which sample will NOT alter the date to the value '2014-02- 15'? $date = new DateTime('2014-03-15');

Options

  • A$date->sub(new DateInterval('P1M'));
  • B$date->setDate(2014, 2, 15);
  • C$date->modify('-1 month');
  • D$date->diff(new DateInterval('-P1M'));

How the community answered

(61 responses)
  • A
    2% (1)
  • B
    8% (5)
  • C
    5% (3)
  • D
    85% (52)

Community Discussion

No community discussion yet for this question.

Full 200-550 Practice