It’s 2015, Update Your Footer.

Posted in Uncategorized on Jan 28, 2015

JavaScript Snippets

This is pure JavaScript, meaning it will refresh the year browser-side, depending on the user’s time settings. Just copy the below snippet and paste it where you want your dynamic text in the footer to appear.

This will just give you:

If you want a bit more information, here’s a snippet you can customize:

Which will give you:

Because JavaScript works on the client (the user’s browser, that is), it is dependent on the user’s settings. In most cases it will likely be what you’d expect. Here’s more info on the JavaScript Date Object.

PHP Snippets

Here’s the same in PHP so you can do this server-side. Use WordPress? Find the ‘footer.php’ in your Editor and add this there (here are videos to help you with that). The below snippet will just show the current year:

This will just give you:

Or if you want more detail in your footer, use something like this:

Or you can go for ($fromYear < $thisYear) in the above to account for any time reversal (or a confused server, more likely). But either will give you:

Since PHP works on the server, it will display the year the server is currently in. Thus, if you look at this from Europe in the wee hours of 2015, you still see 2014 here.

Leave a Reply

Your email address will not be published. Required fields are marked *