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

    We’ve followed the tutorial here: http://ditto.modxcms.com/tutorials/sort-by-a-date-tv.html and looked at the forum posts from that page but we’re still confused on how do get this all working.

    Just to be clear, we have the items sorting the way we’d like, we just can’t change the way the dates appear when the page is displayed: 1242263574 etc

    We have a Template Variable called "nowshowingdate" and its widget is set to Unixtime.

    We have a Chunk with a Ditto call which is:
    [!Ditto? &parents=`6` &sortBy=`nowshowingdate` &dateSource=`nowshowingdate` &sortDir=`ASC` &dateFormat=`%c` &tpl=`dittomoviesumimage`!]
    


    Any suggestions welcome.

    Cheers

      • 36592
      • 970 Posts
      I suppose you have [+nowshowingdate+] in your Ditto template (dittomoviesumimage).
      Use [+date+] instead of [+nowshowingdate+].
        • 5532
        • 251 Posts
        So just use a generic placeholder. not my TV?
          • 5532
          • 251 Posts
          Thanks - worked like a charm when using a Ditto call.

          But how do you get it working on the actual content page. The date is either still in Unixtime format or if I use [+date+] in the page template (like I did in the chunk) it won’t display anything.
            • 16278
            • 928 Posts
            Ditto is formatting the date either directly using strftime() or with its own copy of PHx. Outside of Ditto you can format the Unixtime date either by installing PHx as a plugin, and using its built-in modifier and your original TV:
            [*nowshowingdate:date=`%c`*]

            or by creating a little snippet to do the conversion, e.g.:
            [!formatDate? &uTime=`[*nowshowingdate*]` &dateFormat=`%c`!]

            <?php
            // Snippet formatDate
            $output = strftime($dateFormat,$uTime);
            return $output;
            ?>

            cool KP



              • 5532
              • 251 Posts
              Thanks guys, that did the trick - I’m completely new to Modx and PHP so thanks for helping out.