Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9788

Time until Specified Date

$
0
0

Looking to add an auto-updated amount of time countdown timer into Google Slides with the working script from this question.

Getting Setup

  1. Go to Google Slides
  2. Create a text box, right click to find Alt text and input "$date" under Description
  3. Go to Tools>Script Editor
  4. Add the function below
  5. 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);
      }
    }
  }
}

Viewing all articles
Browse latest Browse all 9788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>