Looking to add an auto-updated amount of time countdown timer into Google Slides with the working script from this question.
Getting Setup
- Go to Google Slides
- Create a text box, right click to find
Alt text
and input"$date"
under Description - Go to
Tools
>Script Editor
- Add the function below
- Output should be PST Current Date
Right now, the output is the current date (12/25/2019
). I'd like to input a manually specified date (eg December 25th, 2030 or 12/25/2030
) to have the resulting output be 11 years, 0 months, 3 days
.
function onOpen() {
var date = Utilities.formatDate(new Date(), "PST", "M/d/yyyy");
var pattern = "\\b\\d{1,2}/\\d{1,2}/\\d{4}\\b";
var slides = SlidesApp.getActivePresentation().getSlides();
var slidesLength = slides.length;
for (var i = 0; i < slidesLength; i++) {
var shapes = slides[i].getShapes();
var shapesLength = shapes.length;
for (var j = 0; j < shapesLength; j++) {
if (shapes[j].getDescription() == "$date") {
var textRange = shapes[j].getText();
textRange.clear();
textRange.insertText(0, date);
}
}
}
}