Body: <p>In <code>general.php</code> I've set <code>'timezone' =&gt; 'Europe/Oslo'</code>.</p>
  <p>When saving entries through the CP they are saved with the correct time. Also, <code>date_default_timezone_get()</code> from my plugin returns <code>Europe/Oslo</code>.</p>
  <p>However when I save something via the plugin, e.g.</p>
  <pre><code>$something = new Something();
  ...
  $something-&gt;save();
  </code></pre>
  <p>the <code>dateCreated</code> field saves with the wrong time. In my case; 2 hours earlier than the <code>Europe/Oslo</code> time.</p>
  <p>What am I missing here?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-03T15:05:25.910Z
Comments.Text: Which plugin are you referring to? Something public, or something you wrote yourself?
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-06T10:41:31.800Z
Comments.Text: I wrote it myself
Comments.UserDisplayName: Stian Karlsen
Tags: <plugin-development>
Title: Timezone in Craft different from timezone in plugin
ThreadText: # Timezone in Craft different from timezone in plugin
  
  (Asked by: username_0 on 2020-08-03)
  
  In `general.php` I've set `'timezone' => 'Europe/Oslo'`.
  
  When saving entries through the CP they are saved with the correct time. Also, `date_default_timezone_get()` from my plugin returns `Europe/Oslo`.
  
  However when I save something via the plugin, e.g.
  
  ```
  $something = new Something();
  ...
  $something->save();
  
  ```
  
  the `dateCreated` field saves with the wrong time. In my case; 2 hours earlier than the `Europe/Oslo` time.
  
  What am I missing here?
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: Which plugin are you referring to? Something public, or something you wrote yourself?  
  > **username_0**: I wrote it myself  
  
  ---
  
  ## 0 answers
  
  