Time-Zone juggling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a PostgreSQL database chockful of datatype:
"time without time zone"

The times I chucked in there are, like, '7:00 PM' and they all seem
fine...

Until I start trying to generate an RFC 882 datetime stamp. :-(

At that point, the fact that the server lives in Portland OR, and my
times are all based in Chicago means that my output is:
Mon, 03 Apr 2006 17:00:00 PDT
even though the actual date/time in question is REALLY at 20:00 in
Chicago.

I'm just doing the naive:
select whatdate, whattime from ...
list($y, $m, $d) = explode('-', $whatdate);
list($h, $i, $s) = explode(':', $whattime);
$datetime_882 = date(DATE_RFC882, mktime($h, $i, $s, $m, $d, $y));

This is PHP4, and I've done an if(!defined()) define() to get the
DATE_RFC882 constant.

What is the least-stupid way to fix this, and get 20:00 in the
Portland OR server to turn into:
Mon, 03 Apr 2006 20:00:00 CDT
which is what time it really was.

Errrr.  Without changing the schema which means having to re-do
everything else in the application.  That's probably the RIGHT way to
fix it, but that ain't happening.

I've been dinking with gmmktime() and reading about setlocale() but
none of them seem to be the Right Answer.

I got a couple stupid ways I think I could fix it, and I'd rather not
do those, cuz they're stupid. :-)
E.g., str_replace(array('PDT', 'PST'), array('CDT', 'CST'), $datetime);

This time zone stuff always gets me head all spun around, I admit freely.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux