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

    I’ve got a site which is in a different timezone (GMT/DST) from the server it’s running on (PST/PDT) and I’ve edited MODx’s index.php in order to show the correct local time to visitors (Manager config settings don’t fix that):
    if (version_compare(phpversion(),'5.1.0','>'))
    	date_default_timezone_set('Europe/London');
    putenv('TZ=GMT');
    setlocale(LC_TIME,'en_GB');
    

    The problem is that my dev server is in a third timezone and the code is under version control so having these lines in index.php is a bit...messy. I’m thinking it should really be a plugin but what event to attach to so it gets run as soon as possible? Or maybe there’s a better way to do it?

    ---
    Time passes...

    ---
    3 days pass...

    ---
    <justPassingShuriken> Try OnLoadWebDocument and OnLoadWebPageCache!

    ---
    <shuriken> Thanks, that worked!

    ---
    <justPassingShuriken> No problem!

    ---
    <shuriken> Great!

    ---
    ...

    ---
    <olderWiserShuriken> Absolute nonsense. The only reason it appeared to work was that the settings were cached by Apache. So put the code back in config.inc.php (being an already volatile file).