Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>NEW SOLUTION SEE BELOW!</strong></p> <p>If you know the timezone you can simply "add" it to your time.</p> <p>For example:</p> <p>server time: 01/01/01 00:00 the time the user wants: 01/01/01 01:00 the timezone of the user: GMT - 5</p> <p>Just get the time (01/01/01 01:00) and add +5 => 01/01/01 06:00</p> <p>So: your script needs to be executed at 01/01/01 06:00</p> <p>(convert to timestamp where needed)</p> <p>Added a little php to demonstrate</p> <pre><code>&lt;?php $servertime = time(); //timestamp of 01/01/01 00:00 $usertime = "01/01/01 06:00";//database $userUTC = "-5";//database strreplace($userUTC, "-", "+"; $replacetext = $userUTC . " days"; $usertime = strtotime($replacetext, $usertime);//now usertime is in your local timezone $crontime = date("d/m/Y H:i");//the time you want the script to be executed ?&gt; </code></pre> <p>I'm just assuming that the timezone is saved as "-5" for example and not Europe/Amsterdam Just tell me if i'm wrong.</p> <p>edit 14:37</p> <p>This could be a even better solution i think!</p> <pre><code>&lt;?php $usertime = "01/01/01 06:00"; $userUTC = "-5"; $userdate = $usertime . " " . $userUTC; $usertimestamp = strtotime($userdate);//now you have the timestamp with correct timezone $crontime = date("d/m/Y H:i", $usertimestamp);//formatted to the right date echo $crontime; ?&gt; </code></pre> <p>Edit: 25-07-2013 14:26</p> <p>New solution to suit your database:</p> <pre><code>&lt;?php $usertime = "01/01/01 06:00"; $userUTC = "Pacific/Auckland";//get from database $userdate = $usertime . " " . $userUTC; $usertimestamp = strtotime($userdate);//now you have the timestamp with correct timezone $crontime = date("d/m/Y H:i", $usertimestamp);//formatted to the right date echo $crontime; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload