What does 'P' stand for in the DateInterval format?

Shrinath picture Shrinath · Feb 8, 2012 · Viewed 51.9k times · Source

Consider the following example quoted from php manual for DateTime

<?php
  $date = new DateTime('2000-01-20');
  $date->sub(new DateInterval('P10D'));
  echo $date->format('Y-m-d') . "\n";
?>

'D' is for days, what does the 'P' stand for in that formatting?

Answer

Phil picture Phil · Feb 8, 2012

From the manual

Interval specification.

The format starts with the letter P, for "period." Each duration period is represented by an integer value followed by a period designator. If the duration contains time elements, that portion of the specification is preceded by the letter T.