PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
PostgreSql dates: timezone minutes offset not optional

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Date & Time
View previous topic :: View next topic  
Author Message
fvu



Joined: 05 Feb 2007
Posts: 1

PostPosted: Mon Feb 05, 2007 12:00 pm    Post subject: PostgreSql dates: timezone minutes offset not optional Reply with quote

I'm unable to let Date.setDate() handle PostgreSQL dates because PostgreSQL doesn't output timezone minutes offset (e.g. +01:00), only timezone hours offset (e.g. +01).

Is there an easy solution instead of hard-coding an alternative regular expression in Date.setDate? Right now I'm stripping the timezone minutes offset:

Code:
// old
preg_match('/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?(Z|[\+\-]\d{2}:?\d{2})?)?$/i', $date, $regs)
// new
preg_match('/^(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?(Z|[\+\-]\d{2})?)?$/i', $date, $regs)

PostgreSQL example:
Code:
click=> show datestyle;
 DateStyle
-----------
 ISO, MDY
(1 row)

click=> select current_timestamp;
          timestamptz
-------------------------------
 2007-02-05 10:48:15.439931+01
(1 row)


Freddy Vulto
http://www.clickhere.nl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Date & Time All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement