What does ā€œPā€ mean in DateInterval format?

Consider the following example given in php manual for DateTime

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

'D' for a few days, what does the ā€œPā€ mean in this formatting?

+47
Feb 08 '12 at 6:29
source share
2 answers

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 indicator. If the duration contains time elements, that part of the specification is preceded by the letter T.

+79
08 Feb 2018-12-12T00:
source share
+15
08 Feb 2018-12-12T00:
source share



All Articles