We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10226
    • 412 Posts
    I am using PHx at the moment, mostly for date manipulation. I have it installed and working, so I thought? I tested a few things with the simple stuff such as :ucase - on to the issues. I installed the ’:timesince’ modifier. That kills anything I try to use it on. This is true for even built-ins like pub_date. My biggest worry right now is this one.

    [+birthday:date=`%m.%d.%Y`+]


    That outputs 31.12.1969! And that happens with any date a I throw it. This is being called via Ditto, but cached or not, it does the same thing.

    Any ideas?
      • 7231
      • 4,205 Posts
      That is the dafault time (as if it were balnk). Are you sure that phx is installed correctly? Seems like there is something that is not processing. Make sure that the correct events are set in the plug in manager, I think it only needs OnParseDocument. If that is correct then it may be a conflict with another script, in which case you need to Edit Plugin Execution Order by Event.

        [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]
        • 10226
        • 412 Posts
        I double checked - I did everything ’by the book’. Is there a simple page I can make to test a few things? I enabled logging and the only thing I see that may be a problem is this...

        12 [10:52:50] MODx / PHx placeholder variable: title
        13 [10:52:50]   |--- Skipping - hasn't been set yet.


        That is the closest to an error as I see. And I am not sure where that is from either.
          • 25830
          • 19 Posts
          Are you sure birthday has the correct value? Have you tried to output birthday without phx modifiers?
          • Keep in mind that most date formatting functions in PHP expect a timestamp to start with, while most date inputs in MODx (especially those that use the javascript calendar picker widget) create a date and time (usually in the form of mm-dd-yyyy h:m:s), so trying to use a formatting function on that will be trying to work with an invalid timestamp, thus causing the output of the default beginning of the Unix epoch in 1970 (or 12-31-1969).

            To properly use the date formatting functions, a script first needs to use the strtotime() function, converting a date/time string to a Unix timestamp.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 10226
              • 412 Posts
              what would be the easiest way to do this? the time doesn’t matter, only the date is what I need to work with.
                • 7231
                • 4,205 Posts
                This is how I would do it. In 096x I use utility snippets rather than PHx to avoid the extra plugin and possible conflicts. I love using PHx inside snippets tpl like ditto, maxigallery and jot.
                <?php
                // [[myDate? &date=`[*birthday*]`]]
                // check input fields
                $date = isset($date) ? $date : "";
                $format = isset($format) ? $format : "%m.%d.%Y";
                
                // only process the date if a value exists
                if($date != ""){
                	$output = strftime($date, $format);
                } else {
                	$output = "";
                }
                
                return $output;
                	
                ?>


                Please note that the date TV needs to be unixtistamp for this to work.
                  [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]