title: Why would PHP date() function give inconsistent times? Off by 2 hours out of the blue
body: <p>I have a page where I get a date/time to insert into a MySQL database.</p>
  
  <p>The timezone the server in is two hours ahead.</p>
  
  <p>In my php.ini I have <code>date.timezone = America/Los_Angeles</code></p>
  
  <p>I noticed sometimes the time was off by two hours.   </p>
  
  <p>MySQL field is type datetime, not null (and I just notice I haven't set default value)</p>
  
  <p>I'm using Codeigniter, if that matters.</p>
  
  <p>This is how I get the time to insert into the database:</p>
  
  <p><code>$newData['time'] = $time = date("Y-m-d G:i:s");</code></p>
  
  <p>I inserted a line of code after that to write the time to the error log.</p>
  
  <p><code>log_message('error', "Date time is $time");</code></p>
  
  <p>Why is the time changing like this?  This portion of the log is from 2:00pm to 2:30pm local time.</p>
  
  <p>This is all coming from a single page on my site in the span of 29 minutes.</p>
  
  <pre><code>110 ERROR - 2011-12-20 14:00:57 --&gt; Date time is 2011-12-20 14:00:57
  111 ERROR - 2011-12-20 14:01:38 --&gt; Date time is 2011-12-20 14:01:38
  112 ERROR - 2011-12-20 14:01:57 --&gt; Date time is 2011-12-20 14:01:57
  113 ERROR - 2011-12-20 16:02:19 --&gt; Date time is 2011-12-20 16:02:19
  114 ERROR - 2011-12-20 16:02:28 --&gt; Date time is 2011-12-20 16:02:28
  115 ERROR - 2011-12-20 14:03:26 --&gt; Date time is 2011-12-20 14:03:26
  116 ERROR - 2011-12-20 14:03:32 --&gt; Date time is 2011-12-20 14:03:32
  117 ERROR - 2011-12-20 14:03:46 --&gt; Date time is 2011-12-20 14:03:46
  118 ERROR - 2011-12-20 14:04:43 --&gt; Date time is 2011-12-20 14:04:43
  119 ERROR - 2011-12-20 14:04:53 --&gt; Date time is 2011-12-20 14:04:53
  120 ERROR - 2011-12-20 14:04:58 --&gt; Date time is 2011-12-20 14:04:58
  121 ERROR - 2011-12-20 14:05:03 --&gt; Date time is 2011-12-20 14:05:03
  122 ERROR - 2011-12-20 16:07:05 --&gt; Date time is 2011-12-20 16:07:05
  123 ERROR - 2011-12-20 16:07:25 --&gt; Date time is 2011-12-20 16:07:25
  124 ERROR - 2011-12-20 16:07:54 --&gt; Date time is 2011-12-20 16:07:54
  125 ERROR - 2011-12-20 16:08:05 --&gt; Date time is 2011-12-20 16:08:05
  126 ERROR - 2011-12-20 16:08:15 --&gt; Date time is 2011-12-20 16:08:15
  127 ERROR - 2011-12-20 16:09:04 --&gt; Date time is 2011-12-20 16:09:04
  128 ERROR - 2011-12-20 16:09:14 --&gt; Date time is 2011-12-20 16:09:14
  129 ERROR - 2011-12-20 16:09:44 --&gt; Date time is 2011-12-20 16:09:44
  130 ERROR - 2011-12-20 16:10:08 --&gt; Date time is 2011-12-20 16:10:08
  131 ERROR - 2011-12-20 16:10:27 --&gt; Date time is 2011-12-20 16:10:27
  132 ERROR - 2011-12-20 14:12:16 --&gt; Date time is 2011-12-20 14:12:16
  133 ERROR - 2011-12-20 14:15:30 --&gt; Date time is 2011-12-20 14:15:30
  134 ERROR - 2011-12-20 14:16:20 --&gt; Date time is 2011-12-20 14:16:20
  135 ERROR - 2011-12-20 14:17:55 --&gt; Date time is 2011-12-20 14:17:55
  136 ERROR - 2011-12-20 14:18:51 --&gt; Date time is 2011-12-20 14:18:51
  137 ERROR - 2011-12-20 14:19:16 --&gt; Date time is 2011-12-20 14:19:16
  138 ERROR - 2011-12-20 14:20:08 --&gt; Date time is 2011-12-20 14:20:08
  139 ERROR - 2011-12-20 14:27:29 --&gt; Date time is 2011-12-20 14:27:29
  140 ERROR - 2011-12-20 14:29:31 --&gt; Date time is 2011-12-20 14:29:31
  141 ERROR - 2011-12-20 14:29:55 --&gt; Date time is 2011-12-20 14:29:55
  </code></pre>
  
  <p>Can anyone shed some light on this for me?</p>
  
  <p>Thanks,</p>
  
  <p>Mark</p>