We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21800
    • 174 Posts
    Hello ,
    I have two snippets (ditto, easyEvents), each of it uses date/time input for processing sort etc. One neets a tv with unixtime (ditto), one a tv with "Date Formatter" (ee).
    Now how can I build a tv that gets the Time input from a unixtime StartTime tv and put it out as Date Formatter Starttime (or maybe contrariwise) automatical?
    So that the editor only has to input the date/time once only instead of inputting it twice for each snippet.

    any help is appreciated
      • 26482
      • 138 Posts
      I solved this by having my TVs all storing unixtime numbers, using these to sort my Ditto output. A tiny snippet dataFormat

      <?php
      return strftime($dateformat,intval($timestamp));
      ?>


      ...transforms the unixtime number into a pretty date.

        • 36592
        • 970 Posts
        Yes. DateTime snippet do the same thing.
        You can put following code as a default value of another TV, which output human readable date&time.
        [!DateTime? &timestamp=`[*Unixtime_TV_Name*]`!]
          • 21800
          • 174 Posts
          Thanx a lot for that answers,
          but they somewhat pass my problem. The unixtime tv is OK for ditto and works perfekt.
          But easyEvents (a snippet) needs a Date Formatter type of tv. So till now I*ve to input date/time information for events twice one for ditto to work and the Date Formater type of tv for ee to work. ee needs this tv and it can’t be given in the ee call like "&datesouce=’Starttime*" or equal.
          It must be a tv with something like this I think: "get the date/time from ’unixtimeTv’ for this document and output as ’DateFormatterTv’ for this document".
            • 26482
            • 138 Posts
            I have EasyEvents running whereby both the Start and End date are formatted as unixtime.
              • 21800
              • 174 Posts
              damned! Pretty easy the world can be. Thanx a million.
                • 3349
                • 126 Posts
                Quote from: sderuiter at Oct 28, 2008, 03:42 AM

                I solved this by having my TVs all storing unixtime numbers, using these to sort my Ditto output. A tiny snippet dataFormat
                <?php
                return strftime($dateformat,intval($timestamp));
                ?>

                ...transforms the unixtime number into a pretty date.

                Can someone please give me more information as to how this works? Where do you call the snippet from?

                I have a unixtime tv that is displaying in an unreadable fashion? How can I change it?

                Thanks
                  • 7231
                  • 4,205 Posts
                  To format your dates in Ditto you have a few options:
                  1) You can use the DateTime snippet linked a few posts above.

                  2) Ditto allows you to format 1 date field and use it with the [+date+] placeholder. Define the variable with &dateSource=`tv_to_use` then format it with &dateFormat=`%B %d - %c` see the tutorial here: http://ditto.modxcms.com/tutorials/sort-by-a-date-tv.html

                  3) Use PHx (available to use in Ditto tpl by default) to format the date. Place [+tv_name:date=`%d.%m.%Y`+] where you want the formatted date to show and presto.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 3349
                    • 126 Posts
                    Quote from: dev_cw at Dec 01, 2008, 07:05 AM

                    To format your dates in Ditto you have a few options:
                    1) You can use the DateTime snippet linked a few posts above.

                    2) Ditto allows you to format 1 date field and use it with the [+date+] placeholder. Define the variable with &dateSource=`tv_to_use` then format it with &dateFormat=`%B %d - %c` see the tutorial here: http://ditto.modxcms.com/tutorials/sort-by-a-date-tv.html

                    3) Use PHx (available to use in Ditto tpl by default) to format the date. Place [+tv_name:date=`%d.%m.%Y`+] where you want the formatted date to show and presto.

                    Thanks, I’ve had success with PHx. HOWEVER, If there is not a date set for the event im showing, how can ensure that the value Thu 01 Jan 1970 isn’t displayed? I’d rather just have nothing displayed....

                    bS