We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10449
    • 956 Posts
    I have problems using the Date Formatter widget in my TV.

    I’m using a couple of TVs for a concert listing. One of the TVs is for entering the event-date.
    Now, although I used the Date Formatter widget with date format
    ’%Y-%m-%d %H:%i:%s’ (without the quotes of course) + input type "Date",
    the output is not what I expected.

    Instead of:
    18-08-2007 21:00:00

    I get this:
    2007-08-18 21::

    Both in the single documents, as well as in the Ditto-output.

    Why?

    The reason I’m reformatting it, is for Ditto to be able to sort the events in descending order:
    [!Ditto? &tpl=`gigListing` &sortBy=`gigDatum` &sortDir=`DESC` &debug=`1`!]
    Thing is... the sorting works fine, but the output misses minutes and seconds.

    Anyone have a solution for this?

    Or maybe it’s possible somehow to change the date-picker to use my date format (= mysql date format) from the get-go?
    This would eliminate the need to use the date formatter altogether.
      • 10449
      • 956 Posts
      btw, I just checked the value in mySQL: It’s correct (i.e. modx_site_tmplvar_contentvalues / 18-08-2007 21:00:00)
        • 10449
        • 956 Posts
        No one? I can’t imagine that I’m the first one to encounter such a problem. This occurs on both v. 0.9.5 + 0.9.6, btw.
        Is there a bugfix / hack / workaround for that?
          • 25663 MODX Staff
          • 12,272 Posts
          Never experienced it honestly. Try adding an &dateFormat=`` (or see the call to Ditto with your intended plugin. I don’t think Ditto supports passing through output widget results, just the raw values.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 10449
            • 956 Posts
            It doesn’t only happen with the Ditto call. I’d have written a little snippet to emulate the Ditto call, if that were the only problem.
            It happens in the actual document output as well. I’ve tried various formats only with day/month/year: they work as expected.

            But as soon as I’m using time (e.g. %H:%i:%s) - alone or together with date elements, I either get gibberish (on my *nix installs) or plain nothing (behaviour on Win dev machine).

            Does anyone know where the date formatter php functions/classes are? Maybe I can rewrite it and see how that goes...
              • 1209
              • 49 Posts
              Quote from: ganeshXL at Jun 25, 2007, 11:52 AM

              Why?

              The reason I’m reformatting it, is for Ditto to be able to sort the events in descending order:

              To be able to sort ditto results by actual date (and not by the way it is displayed) use for your TV the Unixtime widget. Then sorting by such TV you’ll get true sorting in chronological order.

              And to display that TV on your pages you can use the snippet DateTime, which uses php strftime function to format the given unix timestamp.

              In that way you are free to display the date in any possible format and still have the right sorting.