X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C57ED78E8 for ; Wed, 12 Oct 2005 16:14:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03336-08 for ; Wed, 12 Oct 2005 19:14:30 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) by svr1.postgresql.org (Postfix) with ESMTP id C4DC7D7819 for ; Wed, 12 Oct 2005 16:14:30 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i6so78643wra for ; Wed, 12 Oct 2005 12:14:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=sqeyBYH+zCAMcHxsDiLeYkUIoTdzVWHnCifnh60VF0vDQovJbZMpR17I3/RKUNiXLSkySB0UXUQ19szbS0/zJJ1j4TS15/i6H5kTUV/+Y3PKaIqetGo+a44+HJsUSfSiXnRiHoKjGCbrSSqve+Fsqiw7GMX3vTjnVXTrjj2hLxg= Received: by 10.54.157.11 with SMTP id f11mr311542wre; Wed, 12 Oct 2005 12:14:32 -0700 (PDT) Received: by 10.54.78.19 with HTTP; Wed, 12 Oct 2005 12:14:32 -0700 (PDT) Message-ID: <32c009ea0510121214x232f57c5w@mail.gmail.com> Date: Wed, 12 Oct 2005 22:14:32 +0300 From: "Milen A. Radev" Reply-To: milen@radev.net To: pgsql-php@postgresql.org Subject: Converting RFC 2822 "timestamp" to timestampz MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.139 required=5 tests=[AWL=0.115, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200510/23 X-Sequence-Number: 3291 I have a RFC2822 timestamp (example: Thu, 21 Dec 2000 16:01:07 +0200). I need to convert it to "timestampz" but I stumbled on the timezone conversion. The code follows: $timestamp =3D date( 'Y-m-d H:i:s O', strtotime( $rfc2822_timestamp) ); Unfortunately the supported formats for timezone in PHP and PostgreSQL differs. Pgsql requires zone name or offset in the format "H:M" (http://www.postgresql.org/docs/8.0/static/datatype-datetime.html#DATATYPE-= TIMEZONE-TABLE). The "date" function in PHP (versions up to 5.0) supports the following two formats: "Difference to Greenwich time (GMT) in hours. Example: +0200" and =09"Timezone offset in seconds: -43200 through 43200". Of course I could play a little bit with last number (converting it to "hours:minutes") but it seems unnatural. Am I missing something? -- Milen A. Radev