title: How to deal with timezones between server and client?
body: <p>I'm developing a website where I have to deal with different possible timezones from the users. This becomes a great problem since the website hosts time-delicate events like auctions.</p>
  
  <p>All dates/times on the server are in UTC. Database stores everything in UTC timestamps. PHP default timezone is set to UTC too (<code>date_default_timezone_set('UTC');</code>).</p>
  
  <p>Now, my problem is how I should interact with the users, whether I'm only showing a date or, more important, I'm reading a date/time from user input.</p>
  
  <p>A concrete example:</p>
  
  <ul>
  <li>An auction has a deadline, which I store in database as UTC.</li>
  <li>When I view the auction on the website, a javascript timer uses a <code>Date</code> object to calculate the remaining time. It automatically converts the timezone to GMT+0100 (my local timezone). So if the deadline is <code>'2013-08-08 10:46:08'</code> (UTC), the javascript date object will return <code>Aug 08 2013 11:26:15 GMT+0100 (GMT Standard Time)</code>.</li>
  <li>If the current time is greater than 11:46:08 then the timer says that the remaining time is 00:00 (which is correct).</li>
  <li><p>But if I try to insert a bid, the server accepts since the condition on the <code>MySQL INSERT</code> evaluates to <code>true</code>:</p>
  
  <p>INSERT INTO Bids ... WHERE ... AND auction_deadline > NOW() ...</p></li>
  </ul>
  
  <p>( because auction_deadline = <code>'2013-08-08 10:46:08'</code> and NOW() = <code>'2013-08-08 10:26:50'</code>)</p>
  
  <p>All this mumbo jumbo of timezone melts my brains. What am I missing here? I'm almost certain that storing all dates/times in UTC inside the database is the best. I just can't think crystal clear how do deal with it between the user and the database.</p>