I want to be able to localize the time to the specific users locale at some point (for example for user comments) so I set my install to use UTC. Recently an update to "The Events Calendar" (v4.16.17) recommended against UTC because it doesn't account for DST. Here's their logic / explanation: https://theeventscalendar.com/knowledgebase/time-zones/

I understand not using a UTC offset (for example UTC-5) but it doesn't make sense that I can't use UTC as the global default. It seems all date/time functions default to using that as the base of conversion. If I set it to America/New_York and want to convert it to America/Chicago I have to calculate the offset "manually" making sure I understand the "direction" of the conversion. For example:

    $origin_dtz = new DateTimeZone('America/Chicago');
    $remote_dtz = new DateTimeZone('America/New_York');
    $origin_dt = new DateTime("now", $origin_dtz);
    $remote_dt = new DateTime("now", $remote_dtz);
    $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt);

If everything's set to UTC I can do:

    $tz = date_default_timezone_get();
    $date =  date('Y-m-d H:i:s', time());

Even more important with the above I can set the timezone early in the application lifecycle and get the applied timezone application wide. What am I not understanding about Modern Tribes recommendation? How are you localizing the time for each individual user? If I adjust the time via date_default_timezone_set() am I forever screwing myself by having some of the date/time values in UTC (or whatever is set in Settings > General) and some in the timezone the current users provided?

I should note that with respect to "The Events Calendar" my thought process is with the global timezone set to UTC I'd still always individually set the respective "location time zone" for the event.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.