AppScript to auto-populate Google Docs with Created and Last Updated dates
- Open the Google Doc where you want this script to run
- Select Tools > Script editor menu
- Replace the contents of
Code.gs
with this code and Save - In the left side menu, open Triggers
- Create a new trigger which will call function updateFreshness upon event
onOpen
- In your doc or template, insert
{datecreated}
and/or{datemodified}
placeholders where you want the dates inserted. - Refresh the page to see the dates auto-populated.
- On first run, accept permissions to allow the script to run.
- Future edits to the page will update the "Last Updated" metadata of the document so that subsequent views of the page will see the revised modified date.
- The modified date will be in the format
YYYY-MM-DD 📅
and will be highlighted grey to discourage editing. Manually changing the date format or removing the calendar icon will stop automatic updates. The calendar icon links to this repo to provide curious readers with context.
Pull requests welcome!