0

i have a user table with timezone (example: America/Bogota) and the timezone offset (example: -25200).

We have a webserver in germany (Europe/Berlin) and want to send emails on the right moment when the user in usa, africa or asia has 6am.

I getting the offset with the following php code and insert it in the user-table.

function delta_offset( $server_timezone, $user_timezone )
    {
        $dt = new DateTime('now', new DateTimeZone($server_timezone));
        $offset_server = $dt->getOffset();
        $dt->setTimezone(new DateTimeZone($user_timezone));
        $offset_user = $dt->getOffset();
        return $offset_user - $offset_server;
    }

 $server_tz = "UTC";
 $user_tz = $this->input->post( 'timezone' );
 $offset = delta_offset( $server_tz, $user_tz );

It seems that everything works good with the "get timezone and offset"-thing, but i dont know how to query that components in one query to get the user-items.

Can anybody give me some help or hint to solve that?

  • Where are the user items stored? How does the table look like? Which is the attribute there that is time-dependent? How do you remember, if the item was already sent? Why so complicated with php and not using `CONVERT_TZ` as described in https://dev.mysql.com/doc/refman/5.5/en/time-zone-upgrades.html ? – EagleRainbow Jun 01 '16 at 20:46
  • It's unclear where your `$user_timezone` comes from, or how you're applying this information. Be sure you also read "time zone != offset" in [the timezone tag wiki](http://stackoverflow.com/tags/timezone/info). Additionally, you say `"i don't know how to query that components in one query to get the user-items"` but it's unclear what exactly you are *querying* and what *user-items* you are talking about. – Matt Johnson-Pint Jun 01 '16 at 21:12
  • Please read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) in the help center. – Matt Johnson-Pint Jun 01 '16 at 21:13

0 Answers0