Grabbing current year

matthew.wren's Avatar


09 Sep, 2015 05:53 PM

I'm familiar how to do this with Velocity but I'm not sure how to grab the current year using XSLT. I'm looking at update our footer content on our site so we no longer have to manually add the year.

  1. 1 Posted by Ryan Griffith on 09 Sep, 2015 06:47 PM

    Ryan Griffith's Avatar

    Hi Matthew,

    For simplicity, I would definitely recommend using Velocity if you can.

    If you need to use XSLT, do you have the formatting date XSLT by chance? If so, I believe you should be able to call the format-date template without a date parameter and provide a mask of yyyy. This should default to the current date and output the current year.

    Please let me know if you have any questions.


  2. 2 Posted by matthew.wren on 10 Sep, 2015 07:40 PM

    matthew.wren's Avatar

    I went with your recommendation and created a velocity format that grabs the current year. Here's the final format:

    #set ($thisyear = $_DateTool.getYear()) 
    #set($copyright = $_XPathTool.selectSingleNode($contentRoot,"//copyright").value)
        <div id="footerCopyright">
                <!--//** BEGIN:  footerCopyright **//-->
                <div class="footerLogo">
                    <a href="" target="_blank">
                        <img alt="The University of Scranton" height="41" src="/alumni/journal/global/images/footer/scranton-logo-small.gif" width="156"/>
                    Copyright ${thisyear} $copyright
  3. 3 Posted by Ryan Griffith on 10 Sep, 2015 08:31 PM

    Ryan Griffith's Avatar

    Looks about right, Matthew. Additionally, you could use the Locator Tool to grab that copyright value, thus dropping the required Index Block.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 10 Sep, 2015 08:31 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM