title: PHP Get local machine time (windows or linux)
body: <p>I'm writing a php bot which people will be running, this bot requires accurate time in order to function correctly. I'm currently using a timestamp function as follows:</p>
  
  <pre><code>//return string of a timestamp
  private function timestamp()
  {
      $date = date_create();
      return "(" . $date-&gt;format('H:i:s') . ")";
  }
  </code></pre>
  
  <p>Now, I understand that there is a function to set the timezone</p>
  
  <p><a href="http://php.net/manual/en/function.date-timezone-set.php" rel="nofollow">http://php.net/manual/en/function.date-timezone-set.php</a></p>
  
  <p>My issue is that I will have users, users who know very little if not anything about PHP to set the timezones. I can't rely on them to set their own timezones as it will create headaches with formatting and typos, at the very least, if we could set the timezones via numbers instead of locations, for example my timezone is -6...</p>
  
  <pre><code>date_default_timezone_set("-6");  
  </code></pre>
  
  <p>I have found functions of people who have tried to create a function in order to set the local machine's time, but their functions are either outdated or not working.</p>
  
  <p>Is there a function or an alternative robust way to get the local time for either a linux and windows machine for php 5.0+.</p>
  
  <p>Thanks again for your help.</p>
  
  <p>EDIT: even localtime() returns a wrong time...</p>