Every new year, there are messages about “Remember to update your Copyright dates”. There are several JS and PHP snippets flying around that can help you do this. I had an idea today to make this as simple as possible for you. I shipped two updates today to make your lives easier.
Foundation v6.10.6 adds new date helper utility classes
Tardis v1.6.0 has a new Tardis Helper stack. This will be good for non-F6 users/themes.
With these new versions, you can simply place this wherever your copyright goes…
Copyright <span class="current-year">2021</span> My Company
Wherever you place the current-year class, the contents of that will be replaced with the current year on page load. In the example above, I supplied a default of 2021. That will get replaced with the current year (now 2022) on page load.
But wait, there is more…
I figured while I was doing this, why stop at just the year. You have access to the following utility classes. Just like the example above, the current time data will populate where you place the class.
The last 3 classes will actually output an actual full date time string. What is even better is that all output is 100% localized for the website’s language.
You have some flexibility with the formatting. The Tardis stack has options in the stack. With the Foundation 6 utility classes, there is a small JS snippet that is documented in the Utilities class section on the F6 Demo site.
If you don’t have Foundation 6 or Tardis, check them out…
OK. While I would appreciate it if you were to purchase one of the stacks above, here is a free snippet that will give you the same functionality as above from the Copyright example.
Place this in the JavaScript tab in the site wide code in your project.
Maybe you can help me with a different but related issue. Let me explain.
Every time I make an update to a specific page, I time-stamp that update manually. This is not the same as copyright – just the last update to the page. Is there a way to automate that process? It would have to change the time-stamp only when there is an actual change on the page, not every time the page is published. Doable?
My Tardis stack can do this for you as well. It can display the exact date and time that the webpage was published. You have full control over the format as well.
You could only publish the pages that you change, then that would be true.
How else would the page change without publishing it? I guess something like Total CMS. to update the content. You could then use the same CMS to update the date.
@pmjd Regretfully Realmac hasn’t published any changes for RapidWeaver that fixes the inability to change the format of the %last_published% date stamp, since I shared that information back in 2017.
@Rovertek It sounds like you need to buy a copy of my LastPublished stack. It reads the date / time the webpage was last updated and outputs it in any format you want. It will work if you edit the page outside of RapidWeaver (via FTP / text editor) too. But obviously it will not work for dynamic content coming into the page from somewhere else, like AJAX, iFrames, PDF embeds etc.
@Rovertek I’m on my phone currently. I can’t tell if this forum thread is public or not. But it was one of many new and updated addons released last year:
On my sites I just use some simple php code to update my copyright. In my RW project file I go to the General page in Settings. In the Footer field I enter the following:
Sure. Here is some code from w3schools.com showing the next 6 Saturdays.
The example below outputs the dates for the next six Saturdays:
Example
<?php
$startdate = strtotime("Saturday");
$enddate = strtotime("+6 weeks", $startdate);
while ($startdate < $enddate) {
echo date("M d", $startdate) . "<br>";
$startdate = strtotime("+1 week", $startdate);
}
?>