Doc #75083 [Opn->Csd]: Undocumented: IntlDateFormatter->format also accepts DateTimeInterface

From: Date: Tue, 22 Aug 2017 16:14:46 +0000
Subject: Doc #75083 [Opn->Csd]: Undocumented: IntlDateFormatter->format also accepts DateTimeInterface
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14911@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75083&edit=1 ID: 75083 Updated by: cmb@php.net Reported by: zimzat at zimzat dot com Summary: Undocumented: IntlDateFormatter->format also accepts DateTimeInterface -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem PHP Version: 7.1.8 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2017-08-22 16:14:30] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=342913 Log: Fix #75083: IntlDateFormatter::format also accepts DateTimeInterface ------------------------------------------------------------------------ [2017-08-17 09:01:42] zimzat at zimzat dot com Description: ------------ --- From manual page: http://www.php.net/intldateformatter.format --- As of PHP 7.1.5 IntlDateFormatter->format() accepts any DateTimeInterface object, not just DateTime. Test script: --------------- <?php $datetime = new DateTimeImmutable('2017-07-13'); $prettyDateFormatter = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Chicago', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd'); $prettyDateFormatter->setPattern('MMM d yyyy'); echo 'Timestamp: ', $prettyDateFormatter->format($datetime->getTimestamp()) ?: $prettyDateFormatter->getErrorMessage(), "\n"; echo 'DateTime: ', $prettyDateFormatter->format(new DateTime('2017-07-13')) ?: $prettyDateFormatter->getErrorMessage(), "\n"; echo 'DateTimeImmutable: ', $prettyDateFormatter->format($datetime) ?: $prettyDateFormatter->getErrorMessage(), "\n"; Expected result: ---------------- PHP >= 7.1.5: Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: Jul 12 2017 PHP < 7.1.5: Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR PHP >= 7.1.5 has changed signature to: datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR Actual result: -------------- https://3v4l.org/0ErGG Output for hhvm-3.18.4 - 3.21.0, 7.1.5 - 7.2.0beta2 Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: Jul 12 2017 Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.4 Timestamp: Jul 12 2017 DateTime: Jul 12 2017 DateTimeImmutable: datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75083&edit=1

« previous php.doc.bugs (#14911) next »