We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6756
    • 12 Posts
    i’ve set the server offset time in the manager site settings to 5 hours. This is correct. However whenver i use the newslisting or usercomments snipppets the returned time is the local server time (i want it to be GMT) not Australia. any ideas. am i missing something? the [[DateTime]] gives the local time
    • That’s a great question davy__

      I suspect [[DateTime]] does not reference the server offset time declared in the manager.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • That makes the offset value available, but a snippet would have to make use of it ($modx->config[’server_offset_time’]). Like this:

        if(!isset($timestamp)) {
            $timestamp=time();
        }
        $offset = $modx->config['server_offset_time'];
        return strftime("%d-%m-%Y %H:%M:%S", $timestamp + ($offset * 60 * 60));
        
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 6756
          • 12 Posts
          ok guys thanks for that. that’s helpful, i’ll give it a go and let you know smiley
            • 6756
            • 12 Posts

            this line added a lot more time than i wanted

            return strftime("%d-%m-%Y %H:%M:%S", $timestamp + ($offset * 60 * 60));

            behaves better with simply

            return strftime("%d-%m-%Y %H:%M:%S", $timestamp + ($offset));

            i take it i have to modify every snippet to get this to work. has anyone done this for newslisting or usercomments just in case
              • 6756
              • 12 Posts
              i first copied UserComments snippet and renamed to something else (and referred to new snippet)

              I took out the line

              $createdon = time();

              and put in

              $timestamp=time();
              $offset1 = $modx->config[’server_offset_time’];
              $createdon = ($timestamp + $offset1);

              and it seems to work


              Not a programmer at all at all so probably a better way to do it. if whover does snippets could think about offset times too that would be great