Snippets » miscellaneous » Dynamic Year Function
23
Mar
3
Dynamic Year Function
Using this function you can create a dynamic year in the footer of your site. Simply add the function to your Page_Controller class and use $Year in your footer template.
This will output "2009" for this year and then "2009-2010" next year etc.
About the Author
Name: Aram
Comments (3)
-
Great idea. Just one nitpick from the typographer in me, you've used a hyphen to indicate a range, but these look too short, so I've amended it to use an en-dash, which can be called in php with \xe2\x80\x93
Posted by Matthew Balaam, 02/07/2010 8:03am (27 days ago)
-
I've done something similar, but I make it a little more flexible by allowing the template variable take a year as its only parameter.
$Year(2009)
Then it calculates the year range based on what is passed or just uses the current year if no year is provided.Posted by Matt Bower, 25/03/2010 2:01pm (4 months ago)
-
It's good example for a custom PHP function.
You can also use:
$Now.YearPosted by Adam Dening, 17/08/2009 7:52pm (12 months ago)
RSS feed for comments on this page RSS feed for all comments