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?
'P' stands for Period. see here http://php.net/manual/en/dateinterval.construct.php.
The span of time between a specific start date and end date.
PHP | DatePeriod getDateInterval() Function The DatePeriod::getDateInterval() function is an inbuilt function in PHP which is used to return the date interval for the given date period. Syntax: DateInterval DatePeriod::getDateInterval( void )
P = static embargoes – so P1M would always be access previous month ongoing, or P1Y would always be access not available for current 12 months only past 1 year. “D” = days, “M” = months, “Y”= year.
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.
'P' stands for Period. see here http://php.net/manual/en/dateinterval.construct.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With