<p>I solved that by adding a dropdown field to user profiles where I allowed users to select timezone and then in custom module set the selected timezone like this:</p>
<pre><code>class SiteModule extends Module
{
   public function __construct($id, $parent = null, array $config = [])
   {
       // Set correct Timezone
       $currentUser = Craft::$app-&gt;getUser();
       if ($currentUser) {
           $user = $currentUser-&gt;getIdentity();
           $timezone = null;
           if ($user-&gt;userTimeZone-&gt;value) $timezone = $user-&gt;userTimeZone-&gt;value;
           if ($timezone) {
               Craft::$app-&gt;setTimeZone($timezone);
           }
       }

       ...
</code></pre>
<p>If user is not logged in or does not have a timezone set Craft will use the system timezone for those users.</p>
<p>Timezone dropdown values are in the form '<em>America/Chicago</em>'.</p>

CC BY-SA 4.0
2021-01-12T09:31:36.413Z
2021-01-13T08:45:17.767Z
2021-01-13T08:45:17.767Z
Mato
<p>We are creating a small site to manage meetings that take place in many timezones. Administrators of the site will create meetings on behalf of teams everywhere. They may be in pacific timezone and receive a request to create a meeting from a team in England.</p>

<p>When creating the entry, the date/time they see if for pacific timezone, and to create the event with the correct time for GMT+1, they must do the math in their head as to what time in PST corresponds to the correct time in GMT+1.</p>

<p>Is it possible to have or add a field to specify which timezone the provided time is in, vs relying on the timezone set in settings?</p>

<datetime><admin><timezone>
Allow user to set timezone from within Craft when entering a time in a date/time field
# Allow user to set timezone from within Craft when entering a time in a date/time field

(Asked by: username_0 on 2020-04-21)

We are creating a small site to manage meetings that take place in many timezones. Administrators of the site will create meetings on behalf of teams everywhere. They may be in pacific timezone and receive a request to create a meeting from a team in England.

When creating the entry, the date/time they see if for pacific timezone, and to create the event with the correct time for GMT+1, they must do the math in their head as to what time in PST corresponds to the correct time in GMT+1.

Is it possible to have or add a field to specify which timezone the provided time is in, vs relying on the timezone set in settings?

**Tags:** datetime, admin, timezone

---

## 1 answers

### Answer by username_1 on 2021-01-12. Score: 1

I solved that by adding a dropdown field to user profiles where I allowed users to select timezone and then in custom module set the selected timezone like this:
class SiteModule extends Module
{
   public function __construct($id, $parent = null, array $config = [])
   {
       // Set correct Timezone
       $currentUser = Craft::$app->getUser();
       if ($currentUser) {
           $user = $currentUser->getIdentity();
           $timezone = null;
           if ($user->userTimeZone->value) $timezone = $user->userTimeZone->value;
           if ($timezone) {
               Craft::$app->setTimeZone($timezone);
           }
       }

       ...

If user is not logged in or does not have a timezone set Craft will use the system timezone for those users.
Timezone dropdown values are in the form 'America/Chicago'.


---

