We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16702 ☆ A M B ☆
    • 536 Posts
    Hello,

    How can I change date format?
    /for Polls, Ditto, Quip etc.?/
    P.S> domething like tthat:
    <?php
    /*
     * description: vrashta format na datata i chasa za BG
     * primer: [+string:date_bg=`format`+]
     */
    $format = (strlen ( $options ) > 0) ? $options : '%a, %d %B %Y';
    setlocale ( LC_TIME, 'bg_BG.UTF-8' );
    $date_bg = strftime ( $format, 0 + $output );
    return $date_bg;
    ?>

    Thanks,
    Kristalin
      palma non sine pulvere
      • 22295
      • 153 Posts
      Output filters : http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters
      Use the existing ’:date’ filter, or add your own custom filter.
        • 16702 ☆ A M B ☆
        • 536 Posts
        Quote from: oori at Feb 05, 2011, 07:20 AM

        Output filters : http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters
        Use the existing ’:date’ filter, or add your own custom filter.



        thank you - its work!
          palma non sine pulvere
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          Or see if the addon you use has a &dateFormat (or similar) parameter. Sometimes they also get the date format from the system settings.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 8930
            • 44 Posts
            Here is a snippet I’ve written for that sort of problem : setLocalDate

            <?php
            /*
             * description: localize and format a date
             * 
             * 
             *
             * @author EQUILIBRE WEBDESIGN - Enzo GRAFTIEAUX
             * @copyright 2011
             * @version 0.2
             * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License
             */
            
            /* Get Parameters */
            $date = $modx->getOption('date', $scriptProperties, "");
            if (!$date) return;
            $format = $modx->getOption('format', $scriptProperties, "%d %B %Y");
            $encoding = $modx->getOption('encoding', $scriptProperties, "fr_FR.UTF-8");
            
            // Set Local
            setlocale ( LC_TIME, $encoding );
            // Format date
            $dateEncoded = strftime($format, strtotime($date));
            
            return $dateEncoded;
              Equilibre Webdesign - Conception et r
              • 16702 ☆ A M B ☆
              • 536 Posts
              Quote from: enzo2.0 at Feb 08, 2011, 10:06 AM

              Here is a snippet I’ve written for that sort of problem : setLocalDate

              <?php
              /*
               * description: localize and format a date
               * 
               * 
               *
               * @author EQUILIBRE WEBDESIGN - Enzo GRAFTIEAUX
               * @copyright 2011
               * @version 0.2
               * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License
               */
              
              /* Get Parameters */
              $date = $modx->getOption('date', $scriptProperties, "");
              if (!$date) return;
              $format = $modx->getOption('format', $scriptProperties, "%d %B %Y");
              $encoding = $modx->getOption('encoding', $scriptProperties, "fr_FR.UTF-8");
              
              // Set Local
              setlocale ( LC_TIME, $encoding );
              // Format date
              $dateEncoded = strftime($format, strtotime($date));
              
              return $dateEncoded;


              great! and how i can use this snippet in ditto an example?
                palma non sine pulvere
                • 8930
                • 44 Posts
                I use it with getResources

                Snippet call
                [[!getResources? &parents=`9` &limit=`1` &includeTVs=`1` &tpl=`RappelEvenementTpl`]]


                Template (RappelEvenementTpl)
                                    <h1>[[setLocalDate? &date=`[[+tv.DateTV]]`]]</h1>
                                    <a href="[[~[[+id]]]]">
                                        <div class="Texte Conteneur">
                                          <p>[[+tv.ResumeTV:strip_tags:ellipsis=`150`]]</p>
                                        </div>
                                    </a>



                Works with publishedon field too :
                [[setLocalDate? &date=`[[*publishedon]]`]]


                But not yet for timestamp placeholders (createdon, ...) given by Quip. Those don’t seems to be standard. Work in progress!


                  Equilibre Webdesign - Conception et r
                  • 18373 ☆ A M B ☆
                  • 3,141 Posts
                  Probably cause Quip is already outputting it in some fancy way. Try [[+createdon:strftime]]? Or change the date format QUip is outputting - I recall it having a parameter for that.
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • 8930
                    • 44 Posts
                    Probably cause Quip is already outputting it in some fancy way
                    You are right, Quip format date in Quip snippet L251:
                    $commentArray['createdon'] = strftime($dateFormat,strtotime($comment->get('createdon')));


                    [[+createdon:strftime]]?
                    It doesn’t work because it’s already a formatted string. Changing format with "dateFormat" parameter is a solution but you can’t localize the date.

                    You need to modify Quip to clear formatting step :
                    $commentArray['createdon'] = $comment->get('createdon');


                    and format it with setLocalDate for example :
                    [[setLocalDate? &date=`[[+createdon]]` &format=`%d %B %Y` &encoding=`fr_FR.UTF-8`]]

                    The other solution could be to introduce a localization parameter in Quip?
                      Equilibre Webdesign - Conception et r