php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17988 strtotime fails to parse timestamp type from postgresql
Submitted: 2002-06-26 00:35 UTC Modified: 2003-08-16 15:56 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: jam at newimage dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.2 OS: redhat 7.3
Private report: No CVE-ID: None
 [2002-06-26 00:35 UTC] jam at newimage dot com
- postgresql 7.2.1

- php 4.1.2

- redhat 7.3 with all applicable patches

- field type: timestamp

- strtotime() fails to parse dates of the form "2002-06-25    14:18:48.543728-04" because parsedate.y doesn't know how to        handle a floating point seconds value.

- according to #postgresql, it is not possible to have a timestamp not print the precision, so the issue needs to be handled by php's parsedate.y.

- any other details needed, let me know.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-26 00:50 UTC] jam at newimage dot com
I am attempting to extract a timestamp field from the database and convert it to a php time value. the issue is the value that postgresql hands out for the date-- it contains floating point numbers which parsedate.y doesn't know how to handle.
 [2002-06-26 00:52 UTC] rasmus@php.net
Please go read the docs at the links I supplied.
 [2002-06-26 00:58 UTC] jam at newimage dot com
I have read the docs :)

maybe I've missed something (happens all the time).. could you suggest a way to do what I want without using strtotime()?

I'm missing something.. is there a way to extract the entire date/time string with postgresql functions?
 [2002-06-26 01:05 UTC] jam at newimage dot com
ok. while I believe parsedate.y needs to be updated to handle floating point seconds values (I've done it, it's not hard to patch), I *do* see the value of the documentation you pointed out, and I think I can get the code to work.

thank you for your help.
 [2002-06-26 01:26 UTC] derick@php.net
Please submit that patch then so we can include it.

Derick
 [2002-06-27 14:52 UTC] jam at newimage dot com
--- parsedate.y.old	Thu Jun 27 14:26:11 2002
+++ parsedate.y	Thu Jun 27 14:43:28 2002
@@ -262,4 +262,13 @@
 		}
 	}
+	| tUNUMBER ':' tUNUMBER ':' tUNUMBER '.' tUNUMBER tSNUMBER {
+	    yyHour = $1;
+	    yyMinutes = $3;
+	    yySeconds = $5;
+	    yyMeridian = MER24;
+	    yyDSTmode = DSToff;
+	    yyTimezone = - ($8 % 100 + ($8 / 100) * 60);
+	}
+
 	;
 [2002-06-27 15:08 UTC] jam at newimage dot com
the above patch was generated against php-4.2.1
 [2002-07-02 09:34 UTC] sniper@php.net
Assigned to Derick. He mumbled something about rewrite..


 [2003-08-16 15:56 UTC] derick@php.net
Finally fixed in CVS (PHP 5). The patch included didn't work at all anymore, so I came up with my own version. I might merge this to PHP 4.3.4, but after PHP 4.3.3 has been released.

Derick
 [2010-03-07 20:13 UTC] derick@php.net
Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&revision=295939
Log: - Re-generate mapping files, but now with BC zones as well.
#- Fixes the test case for bug #17988 that used a few of those.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC