title: Setting time according to timezone from database
body: <p>I want to make a system which displays time dependant on the timezone in a particular country. E.g. a table in my database contains country names in one field, and in the column next to it, it will contain GMT-compared timezones like -0100 or -0200.</p>
  
  <p>What I need to do on the webpage then is set current GMT time ($time), and then pull the information from the database and alter $time to be GMT -1 or GMT -2.</p>
  
  <p>Could someone tell me what the easiest way to do this would be please?</p>
  
  <p>Thanks for any help</p>
  
  <p>Edit:</p>
  
  <p>So far I have this code:</p>
  
  <pre><code>    &lt;?php
  
  $time = date("H:i:s", time());
  echo $time;
  echo "&lt;br/&gt;&lt;br/&gt;";
  $myDateTime = new DateTime($time, new DateTimeZone('GMT'));
  $myDateTime-&gt;setTimezone(new DateTimeZone('Antarctica/South_Pole'));
  echo $myDateTime-&gt;format('Y-m-d H:i');
  ?&gt;
  </code></pre>
  
  <p>which seems to do the job, and I could enter into the database 'Antarctica/South_Pole' rather than the GMT-/+ time. Would this do the job OK in the long run?</p>
  
  <p>Also, using this method, would Daylight saving times be worked out OK?</p>