Automatic update of copyright date

With this example, I want to show a copyright notice with the year automatically adjusted. Although this is a follow on from the Push Footer to bottom of viewport tutorial, you can apply this technique to any equivalent scenario.

  1. We start with a page that contains the normal ingredients:

  1. Next, place the Date and Time widget into our document by right-clicking App and choosing Data and Date and Time

  1. Choose the widget and give it an ID and change the Interval to Days

  1. Click the footer to select, double-click to edit, position the cursor after 2019 and click the lightning symbol.

  1. Choose datatime and select the formatting button.

  1. Right-click varDate.datetime, Date and Time and Format Date

  1. Format for the year

NOTE: If you only want the year, i.e. not a data range, then you can remove the original 2019 and the year will automatically update. If you do want the date range, then continue.

  1. We need to compare the current year with the initial year so that we do not double up, e.g. 2019 - 2019. Right-click Format Date and choose Operation

  1. Select the equals operator and 2019 as the value

  1. Right-click equals operator and choose Operation

  1. Choose the ternary operator (?) and give the true part a space (spacebar)

  1. Because the ternary operator is at a wrong level, we need to drag it under the ternary operator until we see a tick, upon which let go and it will find itself on the correct level.

The result is

  1. Click the ternary operator and select Operation

  1. Choose the else part (:slight_smile: of the operator

  1. For the value, we use the lightning bolt

and select datetime:

  1. When the equation is false, we need to have the current year showing after a dash (’ - '). This is done as per following.

  1. As before, the operation is at a wrong level. We need to drag it to the ternary operator similar to what was done in step 12. The result will look like

  1. To format the date, right-click varDate.datetime, choose Date and Time and Format Date

  1. Format the date as a year by choosing Formatting enter the format and choose Select.

  1. Click Select and save your work.

  1. This is the end result after saving your work.

  1. To test your work change the years in the following code:

<p class="text-secondary text-center small mb-0 p-1">© Copyright 2019 {{varDate.datetime.formatDate("yyyy") == 2019 ? " " : (' - ' + varDate.datetime.formatDate("yyyy"))}}. All Rights Reserved.</p>

Changing these to 2012 will show the following result

9 Likes