Todd1
(Todd)
November 12, 2013, 4:46am
1
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 © 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
Richard
(Richard)
November 12, 2013, 12:37pm
2
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
Todd1
(Todd)
November 12, 2013, 10:59pm
4
[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
Joe2
(Joe)
November 12, 2013, 11:01pm
5
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
Todd1
(Todd)
November 12, 2013, 11:25pm
6
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
Tim_Plumb
(Tim Plumb)
November 13, 2013, 9:07am
8
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