Automatic Copyright Date

Someone just contacted me off-list and asked how they could automatically update their copyright date using PHP so I thought I would share it. This is just one of many ways to do it.

Toss this into a markup item, preferably within a p, div, li, dd etc. and make sure to use a .php file extension on your page(s). Of course your server needs to support PHP too. Now the year will auto-increment.

<?php
$time = time () ; // Get current time from the server

$year= date("Y",$time); // Only show the current year

echo “Copyright &copy; 2007 - " . $year . " <a href=your-link-here rel=nofollow>My Home Page</a> | All Rights Reserved”; // Edit as needed.
?>

The output will look like this:

Copyright © 2007 - 2013 My Home Page | All Rights Reserved

Todd
http://xiiro.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

That’s a way too …

… I just throw this in a Markup item, leaving the page extension intact :

Richard


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Easier than that

Copyright blurb blah blah start year - (Current Year action)

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

[Laughs] I should have guessed there was an action. Oh well.

T.

Easier than that

Copyright blurb blah blah start year - (Current Year action)


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

There is also a simpler way with PHP:

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

Joe


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Interestingly it doesn’t work in my CMS, not sure why. Still, I like the brevity. Thanks Joe.

Todd

There is also a simpler way with PHP:

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

freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

My formula has been…

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

freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You should remember that anything injected into the page using JavaScript ‘may’ be invisible to search engines (I’ve read conflicting reports that Google will index simple JS like the document.write example below but not injected Ajax). If that matters to you then use a server-side technology.

Personally I do this in PHP although I’ve been known to use old school Server Side Includes in the past;
http://www.freewayactions.com/test/date.shtml
Regards,
Tim.

On 13 Nov 2013, at 05:21, Ernie Simpson wrote:

My formula has been…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options