We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31337
    • 258 Posts
    Oh! I had misunderstood the problem. I thought he needed the time to be converted to the client’s timezone. If all you need to do is change to the local server time, that’s a no brainer then.
      • 4192
      • 43 Posts
      No. I don’t need to change it to the server’s time - All I need is to take this string:

      03/13/2006 04:45:00

      And convert it to European format, adjusting the time for local time, so to show it as follows:

      13/3/2006 alle ore 11:45

      Following sottwell’s suggestion, I tested the snippet with these lines:

      $timestamp = strtotime($v_LastUp);
      $data = date(’j/n/Y G:i’, $timestamp);
      $output.= "<font size=\"1\"><b> ".$data." </b></font>";

      And I succeeded in correctly formatting the date in the European format:

      13/3/2006 04:45

      Now, the only problem is the addition of a +7 hours difference to the time, so to take into account the local time zone. And possibly adding "alle ore" text between date and time.

      I read the strtotime page of PHP manual, but I didnt’ find how to add a time difference. Can you please point me to the right direction?

      Thanks a million!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You’ll need to add 7 hours to the timestamp you generate; I’m not sure of the math involved, it’s in seconds, so you would need to add 60x60x7 to the timestamp (I think...).

        $timestamp = strtotime($v_LastUp);
        $timestamp += (60x60x7);
        $data = strftime('%x alle ore %X', $timestamp);
        


        %x is the locale-preferred date part, %X is the locale-preferred time part. As far as adding the string, you can add whatever you like in strftime’s first argument in between the format specifiers. The %whatever are just placeholders for formatted data taken from the timestamp.



          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
          • 4192
          • 43 Posts
          OK - thank you so much! smiley
          I finally succeeded in getting that snipped 100% operative. I’m working to translate it back into English: can you please let me know what are the rules to share that snippet with other MODx users?
            • 25663 MODX Staff
            • 12,272 Posts
            Share anything you feel like sharing, no restrictions on helping others. smiley
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I enjoyed this conversation very much, Iearned a lot about handling data/time in php! Good stuff to know.
                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
                • 18760
                • 3 Posts
                Quote from: Bryn at Mar 13, 2006, 09:40 AM

                OK - thank you so much! smiley
                I finally succeeded in getting that snipped 100% operative. I’m working to translate it back into English: can you please let me know what are the rules to share that snippet with other MODx users?

                Hi Bryn!
                where i can download the complete 100% functional snippet?
                thx! (is good in italian language for me)
                  .: MaxiK :.
                  • 12289
                  • 1 Posts
                  I also use this script since more than a year. Quite uncomplicated source code and it functioned 100% until the mid of June of 2006. Then came up a phenomenon that the page did not update the values each hour. After several time website actualiazions (F5 button) it referes to correct updated data. Is there anything faulty with the data providing MSN server?

                  Give thanx for detailed replies and information.

                  http://www.weather.travel-island.com/