 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
fvu
Joined: 05 Feb 2007 Posts: 1
|
Posted: Mon Feb 05, 2007 12:00 pm Post subject: PostgreSql dates: timezone minutes offset not optional |
|
|
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 |
|
 |
|
|
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
|
|