We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16348
    • 64 Posts
    Hi

    I'm on a host where I don't have permissions to set the default timezone i the php.ini file nor in the .htaccess file. After a discussion with the support my only alternative is to use the date_default_timezone_set() command. My question is where the best place is to put the command. I was thinking about a plugin which listens to the OnWebPagePrerender event. Is that a good choise or is there a better alternative?

    // Kristoffer
      • 33968
      • 863 Posts
      Hi Kristoffer, go into System Settings and search for server_offset_time.

      You can't change the timezone but you can use this setting to adjust the 'local' time used by MODx.
      • You could add a call to that function to each of the config.core.php files, or once to the main config.inc.php file, though you would need to reapply this any time you upgrade MODX.

        FWIW, if you are on a host that does not have their server timezone set in the php.ini, you might consider looking for a host that provides more sensible PHP configurations, or at least allows you to override them via .htaccess.
          • 16348
          • 64 Posts
          Thanks for your answers! I will go for the config.inc.php alternative for now.

          The timezone is set to UTC at the server, I just wanted to change that to my home timezone. I'm aware of the limitations on my host and I don't like them but the price is very reasonable. I'm constantly looking for a better solution.

          I haven't really seen where the server offset time in the system settings is used. For example, the timestamps in the error log doesn't use this setting.