title: Javascript/PHP and timezones
body: <p>I'd like to be able to guess the user's timezone offset and whether or not daylight savings is being applied. Currently, the most definitive code that I've found for this is here: </p>
  
  <p><a href="http://www.michaelapproved.com/articles/daylight-saving-time-dst-detect/" rel="noreferrer">http://www.michaelapproved.com/articles/daylight-saving-time-dst-detect/</a></p>
  
  <p>So this gives me the offset along with the DST indicator.</p>
  
  <p>Now, I want to use these in my PHP scripts in order to ouput the local date/time for the user....but what's best for this? I figure I have 2 options:</p>
  
  <p>a) Pick a random timezone which has the same offset and DST setting from the output of timezone_abbreviations_list(). Then call date_timezone_set() with this in order to apply the correct treatment to the time.</p>
  
  <p>b) Continue treating the date as UTC but just do some timestamp addition to add the appropriate number of hours on.</p>
  
  <p>My feeling is that option B is the best way. The reason for this is that with A, I could be using a timezone which although correct in terms of offset/dst, may have some obscur rules in place behind the scene that could give surprising results (I don't know of any but nonetheless I don't think I can rule it out).</p>
  
  <p>I'd then re-check the timezone using Javascript at the start of each session in order to capture when either the user's timezone changes (very unlikely) or they pass in to the DST period.</p>
  
  <p>Sorry for the brain dump - I'm really just after some sort of reassurance that the approaches above are valid.</p>
  
  <p>Thanks,</p>
  
  <p>James.</p>