We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21453
    • 9 Posts
    I’m trying to format a date in a chunk. This is my TV "[*date*].

    It works beautifully, except it outputs nonsense like "31-Dec-09 10:12."

    What I want is 12.31.09, without the timestamp. Soooo, I put in this instead: [+phx:input=`[+date+]`:date=`%m.%j.%y`+].

    It formats properly, but the DATE is wrong. It outputs 12.365.69 for EVERY ENTRY.

    Yo no comprendo.
      • 16278
      • 928 Posts
      According to my references, %j will give you "Day of the year, 3 digits with leading zeros 001 to 366", which explains the 365. %d is a two-digit day of the month, and %e is supposed to give you a single digit with and space before single-digit figures. Not quite what you want, perhaps, but closer.

      So why the same date for any input? 12.365.69 is 2300 GMT on 31st December 1969, or zero hours on 1st January 1970 allowing for DST. This would indicate that your [+date+] is evaluating to zero. That usually happens because the TV contains an invalid date or isn’t using the Unixtime widget for output.

      If [*date*] was giving you the date required, albeit in the wrong format, you should still be using [*date*] with PHx, not the placeholder [+date+]. From my experience using PHx in Ditto tpl chunks, the format [*date:date=`%m.%d.%y`*] would be close to what you are seeking, provided your TV is set to use the Unixtime widget.

      Try setting the widget first and using just [*date*] in your template. If that shows as a 10-digit number, go on to apply the PHx processing to the TV.
      smiley KP
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        In a Ditto template, [*...*] will produce the value of the TV for the page containing the Ditto call. If you want the value of the TV for the individual news page that Ditto is generating a summary/link for, you must use [+...+] placeholders. Keep in mind that Ditto has its own placeholders; your TV names should be created to avoid conflicting with those.
          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
          • 21453
          • 9 Posts
          So yea, I feel a little dumb right now. I just set the %m.%d.%y format in my [*date*] TV and got the result that I needed. . .

          The problem I was having arose from the fact that there was already a format set in the TV, and I was using a different format in the call. I think the conflict made it go haywire.

          Infinite thanks, you two.