Google Slides – How to Insert Current Date/Time Field

google-slides

Is there a way to insert the current date and/or time in Google Slides?

Best Answer

In case someone else finds this, I was able to automate this using Google Apps Scripts which is available under the Tools menu. Here is the script I made which updates any text box that has the description field set to "$date" to the current date every time the presentation is opened.

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);
      }
    }
  }
}