We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26439
    • 104 Posts
    My first attempt at a snippet..... ( was initially not working under Modx, but is now with thanks to sottwell )

    // CopyYears - snippet for MODx
    // Automatically updating copyright date
    // License GPL
    // Written 04-2006
    
    // &startYear - first year of notice
    //              defaults to current year
    // [!CopyYears?startYear=`2005`!]
    
    $spacer = " - ";
    $now = date("Y");
    $startYear = isset($startYear)? $startYear : $now;
    $years = ($now > $startYear) ? $startYear.$spacer.$now : $now;
    return "$years";
    
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      rolleyes it was thanks to sottwell that it wasn’t working right in the first place! But, nice, useful beginning, we’ll be looking forward to seeing what you move on to do!
        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
        • 33337
        • 3,975 Posts
        Nice little snippet man!

        Thanks for sharing smiley

        Oh, you should send some chocolates to Susan wink

        regards,

        zi
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 6726
          • 7,075 Posts
          Yeah thanks will help those copyright footers to stay accurate smiley !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 3186 ☆ A M B ☆
            • 279 Posts
            For MODx Revolution

            <?php
            /**
             * CopyYears
             *
             * Parameters:
             * start - first year of notice defaults to current year
             * spacer - the space string between start and current year
             *
             * [[!CopyYears? &startYear=`2011`]]
             */
            
            $start = $modx->getOption('start', $scriptProperties, date("Y"));
            $spacer = $modx->getOption('spacer', $scriptProperties, ' - ');
            
            $now = date("Y");
            $startYear = isset($startYear)? $startYear : $now;
            $years = ($now > $start) ? $start.$spacer.$now : $now;
            
            return $years;
              MODX Ambassador (NL) & Professional MODX developer
              Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
              MODX e-commerce solution SimpleCart
              • 1343 ☆ A M B ☆
              • 2,213 Posts
              Check in the Package Manager for Copyyears, it’s already there for you wink
                Patrick | Server Wrangler
                About Me: Website | Tweets |  MODX Hosting
                • 3186 ☆ A M B ☆
                • 279 Posts
                I didn’t know that! Great...

                But check my snippet code above, litte improvements ;-)
                  MODX Ambassador (NL) & Professional MODX developer
                  Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
                  MODX e-commerce solution SimpleCart
                  • 32098
                  • 31 Posts
                  I wish I knew how that nice little snippet worked. How the heck does it work out what the year is?

                  In my ignorance I have been using what I am sure is a simpler (and naffer) technique.

                  In the chunk for the footer goes:

                  © 2006 - [[yearecho]]


                  Start year hard-coded into the chunk. Not so bad, is it? Then the nanoscopic yearecho snippet:

                  <?php $year = date('Y'); return $year; ?> 
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Another alternative, is to create a simple, reusable snippet called time:
                    <?php
                    return time();
                    ?>

                    And then use the date output filter:
                    [[!time:date=`%Y`]]
                      • 7045
                      • 225 Posts
                      Quote from: OpenGeek at May 11, 2011, 12:27 PM

                      Another alternative, is to create a simple, reusable snippet called time:
                      <?php
                      return time();
                      ?>

                      And then use the date output filter:
                      [[!time:date=`%Y`]]


                      It’s so simple, it’s perfect. Thanks.