We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12584
    • 208 Posts
    I am sure this has been asked before but I cant find the answer,

    I have a ditto call which has
    &dateSource=`showdate` &dateFormat=`%d-%m-%y`


    the template has the [+date+] placholder but the output date is 01-01-70

    I remember seeing how to resolve this but never bookmarked it can someone point me in the right direction.

    Thanks
      • 7231
      • 4,205 Posts
      &dateFormat=`%d-%m-%y` equals 01-01-70. To change it edit the format to the output you want by using the strftime() format.
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 16278
        • 928 Posts
        If you mean that every date is coming out as 1st Jan 1970, you need to make showdate deliver its date as a timestamp (unixtime widget).

        From Ditto documentation:
        &dateSource
        Purpose
        Source of the [+date+] placeholder
        Options
        # Any UNIX timestamp from MODx fields or TVs such as createdon, pub_date, or editedon

        Then, of course, the fun begins when you want to use showdate, formatted, elsewhere.
        KP
          • 12584
          • 208 Posts
          &dateFormat=`%d-%m-%y` equals 01-01-70. To change it edit the format to the output you want by using the strftime() format.

          Had a look at the link but I guess I would need to have a much better understanding of php to work out to get the output of the [+date+] change it from a MySQL Timestamps to a UNIXTIME format and echo that back out in a ditto widget, would not have a clue where to start  huh

          Had a look for an existing widget to work with my ditto call which proved elusive so think at thing point having the date is not that important  :’(

          Thanks for pointers anyway.
            • 16278
            • 928 Posts
            shocked No PHP required (not absolutely, at any rate)! shocked
            In case you decide to follow it up anyway:
            In MODx ’widgets’ means the output controls for template variables [TVs] (I’m assuming showdate is one). Info at http://sottwell.com/how-template-variables-work.html is more up to date than the main site’s documentation. In the definition of your template variable, you can select ’unixtime’ as the widget, and the data associated with the TV will be translated from most standard date formats, such as 2009-06-14 or 14 Jun 09 or Jun 14 2009, into a Unix timestamp, (a few seconds less than*) the number of seconds elapsed since 1st January 1970. So if your template variable contains a recognizable date format, and has the unixtime widget, it will be returned as a Unix timestamp. If it’s the value for Ditto’s dateSource parameter, Ditto will display it instead of the [+date+] placeholder, using the specified dateFormat (’%d-%b-%y resulting in 14-Jun-09, for example).
            If the date is stored in a format that isn’t recognized, or if no widget is set for a value that isn’t stored in the DB as a timestamp, or a date formatting widget is set in the TV, the PHP function strtotime() that is almost certainly involved behind the scenes will return false or -1, depending on your version of PHP. Either way, that will produce a [+date+] of 1 Jan 1970.
            Ditto has an excellent debugging console - just add &debug=`1` to your snippet call, and your output will be prefaced by a link to the debug console showing exactly what data is being fed to it. You’ll be able to see whether the problems with your date source are on the input or the output side, and chase the bug from there.
            I’m not a great expert on MODx, PHP or Ditto - the above is part of a painful learning process over the past couple of weeks while I’ve been working on an events calendar. Once you do pin down the problems, it’s amazing how flexibly you can use the framework and the snippet.
            KP
            (*cos they didn’t allow for leap seconds)
              • 12584
              • 208 Posts
              Keith

              Thanks for the reply but I am still not sure how to fix this and yes every article shows a date of 01-01-70, I am not using any TV’s at all, the date is somehow being generated by ditto when it outputs the documents list, all I have is a ditto call of this:

              [[Ditto? &startID=`2` &summarize=`5` &removeChunk=`Comments` &dateSource=`showdate` &dateFormat=`%d-%m-%y` &tpl=`ditto_blog` &paginate=`1` &extenders=`summary,dateFilter` &paginateAlwaysShowLinks=`1` &tagData=`documentTags`]] 


              and the template "ditto blog" which the ditto call points to is this:

              <div class="ditto_summaryPost">
                <h3><a href="[~[+id+]~]" title="[+title+]">[+title+]</a></h3>
                <div class="ditto_info" ><!-- By <strong>[+author+]</strong> dont want author for me --    >   [+date+] <br />
              
               <!-- <a  href="[~[+id+]~]#commentsAnchor">Comments
                ([!Jot?&docid=`[+id+]`&action=`count-comments`!])</a>TO MUCH SPAM -->       
              
              </div>
              
              <!-- <div class="ditto_tags">Tags: [+tagLinks+]                  </div> Tag feature not wanted on this  -->  
              
                [+summary+]
                <p class="ditto_link">[+link+]</p><hr /><BR /><BR />
              
              
              
              </div>


              All I have done is copy and paste some the the code from the sample website you get on installation and changed a few bits, I know there are bits that are not really needed in that code its just where I have been testing/learning but I cant work out where I make changes to get the date formatted.

              Maybe its a case I need to use createdon call or something, I turned the debug on and I am not even sure what I am looking for on that, I can see all the parameters that are in the ditto call the only thing refering to the date is this:

              dateFormat %d-%m-%y
              dateSource showdate

              Well thats the extent of my understanding sorry if I seem very slow with.

              Thanks Ian
                • 10487 MODX Staff
                • 1,535 Posts
                Hi Ian,
                every article shows a date of 01-01-70, I am not using any TV’s at all
                I’m confused - just to clarify, you definitely aren’t using TVs? You have ’showdate’ specified as the datesource which means it’s looking for a TV called ’showdate’.

                If you haven’t got that ’showdate’ TV created and assigned to the template that your documents are using (and obviously populated with a date value), then you will get a date of 01-01-70 (which is the equivalent of Ditto not finding the TV value in the database)

                Look at Keith’s previous post on how to setup the ’showdate’ TV - I think that’s your missing link here ... wink
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 12584
                  • 208 Posts
                  ok have solved it and I see why I made things confusing, I have been copy and pasting the Ditto call from posts I have found on the forum, I did not require &dateSource=`showdate` at all as there is no TV set up for that, all I needed was &dateSource=`createdon` along with &dateFormat=`%d-%m-%y` which worked perfect.

                  Now I have a better understanding of how it works I can see why my 1st post was so confusing and hopefully learn from it.

                  Thanks as usual for the support.

                  Cheers

                  Ian