php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79400 PHP does not parse postgres ISO or RFC date times
Submitted: 2020-03-20 20:53 UTC Modified: 2020-03-29 04:22 UTC
From: ce dot ceo at cybercoment dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 7.4.4 OS: alpine
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
28 + 45 = ?
Subscribe to this entry?

 
 [2020-03-20 20:53 UTC] ce dot ceo at cybercoment dot com
Description:
------------
PHP 7.4.1
Postgres 11.6

None of the DateTime format strings successfully parse dates from Postgres's default "ISO" format (Although postgres has its own bugs where they use a space instead of a 'T')

strtotime works but it's a timestamp instead of a datetime.

Test script:
---------------
DateTime::createFromFormat(DateTime::ISO8601, "2021-03-12 20:17:36.922347")
DateTime::createFromFormat(DateTime::RFC3339, "2021-03-12 20:17:36.922347")
DateTime::createFromFormat(DateTime::RFC3339_EXTENDED, "2021-03-12 20:17:36.922347")


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-20 22:12 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2020-03-20 22:12 UTC] requinix@php.net
Is there any particular reason you have to use createFromFormat for this? True, there is no constant that covers their ISO style,
  https://www.postgresql.org/docs/9.1/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT
nor a plain "Y-m-d H:i:s", but as you've seen with strtotime() regular parsing works just fine.
 [2020-03-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 02:01:29 2024 UTC