Tomas Martty

Thoughts & random stuff

Update your © year automatically!

3 months ago · 1 MIN READ

If you have been manually updating the year on your websites/app footer like this folks, you've been doing it wrong...

Google Admob dashboard (requires login) GoogleAdMob.png

YCombinators Legal Page Footer YCombinator.png

Wired Wired.png

Bill Gates blog GatesNotes.png

Mozillas Pocket Pocket.png

Sony Sony.png

OneSignal Onesignal.png

Recode Recode.png Screenshots taken Sunday 13th, January 2019

And I'm sure there's plenty more so either don't include it at all or do it programmatically!

Here's a few examples of how you could achieve it :

Javascript

<script>document.write(new Date().getFullYear());</script>

PHP

<?php echo date("Y"); ?>

Python

import datetime as dt
{{ dt.datetime.now().year }}

Ruby

<%= Date.today.year %>

Now go update your website and let fellow developers know about this simple workaround!

66 claps

···

Tomas Martty

Entrepreneur & Developer

Built with Canvas
Hosted with DigitalOcean