I've been reading up on how to do this all morning, and the general consensus is this: store your timestamps in UTC and calculate the offset from there.
However, like most people, I am maintaining an existing codebase and I can't change the way we store our dates. At least, not in the allotted time frame.
So my question is, can I safely do something like this?
// this is my time zone
$timestamp = strtotime($timestampFromDatabase);
date_default_timezone_set('America/New York');
$tz = date_default_timezone_get();
// this is theoretically their timezone, which will eventually
// be taken from a session variable
date_default_timezone_set('Europe/Paris');
$offset = time() - $timestamp;
$timestamp -= $offset;
// now that I have the offset, display dates like this
date('r', $timestamp);
Some people have advised against doing date arithmetic, but is what I'm doing here wrong? Is there a better way? Are there pitfalls I need to watch out for? I'm particularly interested in what kind of bugs this method could produce, and if any, who will they affect?
My boss is the kind of guy that doesn't care if the bug only affects 1% of the user base.
Edit: Can I make this any clearer? I don't seem to have too many takers on this. Anyone? Even a vague suggestion or a link would be immensely helpful.