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

Answered Time zone issue

    • 51020
    • 670 Posts
    Hi there,

    I have a page which publishes a resource at a specific time each week.

    I'm in the UK and we are currently on British Summer Time.

    So if I want the resource to get published at 5pm, i need to set the publish time at 4pm.
    I've checked my server, and it knows that the time is 5pm, but if I add this to my page:
    [[!+nowdate:default=`now`:strtotime:date=`%c`]]
    


    It print the time as being 4pm!

    In system settings there are two settings:
    Default Time Zone: date_timezone
    Server offset time: 0


    I tried changing the server offset time to 1 to correct it, but this seems to do nothing.
    Even if it DID work, it's not a good solution, because I would have to remember to change it back when the clocks go back or forward (twice a year).

    Any ideas why it's showing a different time to the server time?


    Thanks!
    Andy

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      Try setting the date_timezone System Setting to "Europe/London" (without the quotes).

      If that doesn't do it, try adding this line to a php.ini file in the MODX root (create one if necessary):

      date.timezone = "Europe/London"


      If that doesn't work, check the Date section of PhpInfo() (Manage -> Reports -> System Information -> phpinfo() link) to see what time PHP thinks it is.

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 46886
        • 1,154 Posts
        ha was just gonna say check php time on server side
          • 51020
          • 670 Posts
          Quote from: BobRay at Jun 13, 2018, 09:42 PM
          Try setting the date_timezone System Setting to "Europe/London" (without the quotes).

          If that doesn't do it, try adding this line to a php.ini file in the MODX root (create one if necessary):

          date.timezone = "Europe/London"


          If that doesn't work, check the Date section of PhpInfo() (Manage -> Reports -> System Information -> phpinfo() link) to see what time PHP thinks it is.


          Thanks Bob. The first option worked by setting the date_timezone System Setting to "Europe/London"
          So thank you for that! (I always assumed it would inherit the timezone et by the server)

          I have had a look at the pInfo() within reports, but all I can find is under Date it says 'Default timezone Europe/London'
          I can't find anywhere where it prints what time it thinks it is.

          But the main thing is that your first solution worked. so thank you!

          Andy
            • 3749
            • 24,544 Posts
            Sorry, I mis-wrote. I meant what timezone PHP thinks it is, not what time.

            Glad you got it sorted. smiley
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 51020
              • 670 Posts
              Quote from: BobRay at Jun 14, 2018, 09:45 PM
              Sorry, I mis-wrote. I meant what timezone PHP thinks it is, not what time.

              Glad you got it sorted. smiley

              Ah Ok - thanks Bob!