title: Carbon date time differs
body: <p><strong>Case</strong></p>
  
  <p>Using <code>Middleware</code>, <code>Session</code> &amp; <code>Carbon</code> to check if the <code>session/shopping cart</code> is created <code>longer than 20 minutes ago</code> so the session can be flushed. (Routes are grouped inside the middleware)</p>
  
  <blockquote>
    <p>Current data is being run on Homestead, but same problems occur on my live website which is being run on a Digital Ocean server</p>
  </blockquote>
  
  <pre><code>class CheckCart
  {
      public function handle($request, Closure $next)
      {
          // Defining current timestamp
          $now = Carbon::now();
  
          // created_at from the session
          $created_at = $request-&gt;session()-&gt;get('created_at');
  
          // If the cart count is == 1, &amp; created_at is null -&gt; put created at date in session
          if (Cart::count() == 1 &amp;&amp; $created_at == null) {
              $request-&gt;session()-&gt;put('created_at', $now);
          }
  
          // If created at date + 20 minutes is earlier than current time, flush (empty) session
          if ($created_at != null) {
              if ($created_at-&gt;addMinutes(20) &lt; $now) {
                  $request-&gt;session()-&gt;flush();
              }
          }
          return $next($request);
      }
  }
  </code></pre>
  
  <p><strong>Problem</strong>  </p>
  
  <ul>
  <li><code>Local time</code> from my Macbook is <code>2017-01-06 00:00</code>  </li>
  <li><code>Carbon::now()</code>  is <code>2017-01-05 23:25</code>  </li>
  <li><code>created_at</code> timestamp is (which was eventually set by <code>Carbon::now()</code>) is <code>2017-01-06 03:20</code></li>
  </ul>
  
  <p>How can these timestamps differ so much, and especially, how can <code>created_at</code> which defined by <code>Carbon::now()</code> at some point be at least 7 hours later?</p>
  
  <ul>
  <li>All timezones are <code>Europe/Amsterdam</code></li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/TBlXx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TBlXx.png" alt="image with code &amp; timestamps"></a></p>