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

    I have this probleme, I have a date TV (eCalendrierDateTV) the %b wich is the Short month name like found in the documentation : https://rtfm.modx.com/revolution/2.x/making-sites-with-modx/commonly-used-template-tags/date-formats it return the full month name

    the TV call in the chunk is :
    [[!+eCalendrierDateTV:strtotime:date=`%e %b %Y`]]

    wich result in
    1 avril 2016

    when it should be
    1 avr. 2016

    but it's working when I do it like so:
    [[!+eCalendrierDateTV:date=`%e %b %Y`]]

    without the strtotime but then the probleme is that it only give me one date
    31 dec. 1969

    anyone has a clou on what might be causing this and how to fix this?

    thanks all
      • 3749
      • 24,544 Posts
      Are you on a Windows platform? %e is not supported there, though I don't see why that would affect the month.

      The MODX time and date modifiers are confusing. The :date modifier actually calls strftime() rather than date() and it doesn't default to the current date/time, like the real strftime() does.

      I'm assuming that your +eCalendrierDateTV tag returns a human-readable date. The strftime() function requires a Unix timestamp as input, so the :strtotime modifier turns it into one (this is why your call without :strtotime returns the 1969 date).

      Try this:

      [[!+eCalendrierDateTV:strtotime:date=`%d %b %Y`]]
        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
        • 8548
        • 104 Posts
        Quote from: BobRay at Mar 23, 2016, 01:31 PM
        Are you on a Windows platform? %e is not supported there, though I don't see why that would affect the month.

        The MODX time and date modifiers are confusing. The :date modifier actually calls strftime() rather than date() and it doesn't default to the current date/time, like the real strftime() does.

        I'm assuming that your +eCalendrierDateTV tag returns a human-readable date. The strftime() function requires a Unix timestamp as input, so the :strtotime modifier turns it into one (this is why your call without :strtotime returns the 1969 date).

        Try this:

        [[!+eCalendrierDateTV:strtotime:date=`%d %b %Y`]]

        Thank's BobRay for the explanation, I understand better the time format in modx now.

        eCalendrierDateTV is a Date TV, so it does return a humane date.


        I'm on unix server,
        %e returns the day number without the preceding zero wich is ok, when I replace with the %d it returns the day number with the zero like it's supposed to.
        the problem is with the %b wich is supposed to return the Short month name (example: Apr.) and %B the complete month name (example: April).

        that's my probleme, I need the Short month name, but it's not working sad

        many thanks for helping me try to fiture this out.
          • 3749
          • 24,544 Posts
          What does this show by itself in the same location?

          [[!+eCalendrierDateTV]]
            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
            • 8548
            • 104 Posts
            Quote from: BobRay at Mar 23, 2016, 11:48 PM
            What does this show by itself in the same location?

            [[!+eCalendrierDateTV]]

            I get this : 2016-04-01 19:00:0
              • 3749
              • 24,544 Posts
              It's weird. This code works for me:

              $x = strtotime('2016-04-01 19:00:0 ');
              echo strftime('%d %b %Y', $x);
              // result: 01 Apr 2016


              If I use %e instead of %d, I get nothing (but I'm on Windows).

              You could try creating your own snippet with the code above and sending it the TV tag as a property. I don't know what else to suggest.
                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
                • 8548
                • 104 Posts
                Quote from: BobRay at Mar 24, 2016, 03:24 PM
                It's weird. This code works for me:

                $x = strtotime('2016-04-01 19:00:0 ');
                echo strftime('%d %b %Y', $x);
                // result: 01 Apr 2016


                If I use %e instead of %d, I get nothing (but I'm on Windows).

                You could try creating your own snippet with the code above and sending it the TV tag as a property. I don't know what else to suggest.

                Thank you BobRay, I will try that, thank you very much, like always your of good help.

                I'll post back if it works