We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16544
    • 86 Posts
    Hi guys! I’m just trying to format my &dateFormat in my Ditto call. This is what I have:

    &dateFormat=`%e %b. %Y`

    and I’m getting this: Oct. 2010

    But this is the output I need:

    Oct
    11
    2010


    This is the code
    <h1><a href="[~[+id+]~]">[+title+]</a></h1>
    <p>[+date+]</p>
    <p>[+summary+]</p>
    <p>[+link+]</p>

    and
    [!Ditto? 
    &parents=`2` 
    &extenders=`summary` 
    &tpl=`tplBlog` 
    &orderBy=`createdon ASC` 
    &display=`6` 
    &truncText=`Read more...` 
    &dateFormat=`%e %b. %Y`!]


    I’ve been trying with no success. I even tried %n for a new line and it didn’t work. Any help? Thanks! undecided
      I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
      • 16278
      • 928 Posts
      It’s possible that %e doesn’t work on your system - according to the PHP manual,
      Not all conversion specifiers may be supported by your C library, in which case they will not be supported by PHP’s strftime(). Additionally, not all platforms support negative timestamps, so your date range may be limited to no earlier than the Unix epoch. This means that %e, %T, %R and, %D (and possibly others) - as well as dates prior to Jan 1, 1970 - will not work on Windows, some Linux distributions, and a few other operating systems.
      There’s a workaround for Windows further down that manual page.

      Try &dateFormat=`%b
      %d
      %Y
      `

      smiley KP

        • 16544
        • 86 Posts
        Yes, %e wasn’t working, &dateFormat=`%b
        %d
        %Y
        `
        is not working either, i get a funky character. undecided


          I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
          • 16544
          • 86 Posts
          The thing is that all the
          inside the `` are render as string and you get `Nov.
          13,
          2010
          `. So far I just applied a class with a fixed width to it to brake the lines and get:

          Nov.
          13
          2010


          I wonder if there is a way to have something like:
          &dateFormat=`%b`
          &dateFormat=`%d`
          &dateFormat=`%Y`

          so I can add a class each one of them.

          Thanks grin
            I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.
            • 16278
            • 928 Posts
            Two ways around this:

            - if you are editing your Ditto call using the rich-text editor (TinyMCE), yes, tags and so on will be turned into entities like this. You can insert a line break in TinyMCE using Shift+Enter in the editor, and that should be preserved in your output. But it makes your snippet call look rather messy.

            - instead of using &dateFormat in the snippet call, you can use the built-in PHx (placeholders extended) output modifiers in your template chunk. There is a modifier for date, so your output chunk could read:
            <div class="myDateBlock">
            <p>[+createdon:date=`%b`+]</p>
            <p>[+createdon:date=`%d`+]</p>
            <p>[+createdon:date=`%Y`+]</p>
            </div>

            Ditto has built-in PHx for handling its output chunks. See the Wiki (http://wiki.modxcms.com/index.php/PHx) fr details of how it operates.
            smiley KP
              • 16544
              • 86 Posts
              Cooooooooool! Thank you very much kp52! grin
                I had fainted, unless I had believed to see the goodness of the LORD in the land of the living.