Google Script for adding timer
<p>I am trying to create a google script which consist of 2 button "start" and "stop". Clicking "Start" will start a timer and clicking "stop" will stop a timer.</p>

<p>I do know I cant achieve this using setTimeout or setInterval, so I used utilities.sleep(1000) . But using this I cant execute the function more than 5 minutes because of limitation set by Google.</p>

<p>Hence I tried using Trigger methods setting at 1 second, but no luck. The triggering is not happening at all.</p>

<p>I am sharing the code below any help is appreciated.</p>

<pre><code>function onClickStart(){
  startTimer();
}

function startTimer() {
  removeJobs();
  ScriptApp.newTrigger("timer")
  .timeBased()
  .after(1000)
  .create();

  timer();
}

function removeJobs() {    

  PropertiesService.getScriptProperties().deleteAllProperties();
  var triggers = ScriptApp.getProjectTriggers();
  for (i=0; i&lt;triggers.length; i++) {
    ScriptApp.deleteTrigger(triggers[i]);
  }
}

function timer() {
  var seconds = 0, minutes = 0, hours = 0,
    t,stop_time;

  var documentProperties = PropertiesService.getDocumentProperties();
  var timer = documentProperties.getProperty('timer_result');
  Logger.log('get timer: %s', timer);
  if(timer){
    timer = timer.split(':');
    seconds = +timer[2] || 0 ;
    minutes = +timer[1] || 0 ;
    hours = +timer[0] || 0 ;
  }
    seconds++;
    if (seconds &gt;= 60) {
        seconds = 0;
        minutes++;
        if (minutes &gt;= 60) {
            minutes = 0;
            hours++;
        }
    }

    stop_time = (hours ? (hours &gt; 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes &gt; 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds &gt; 9 ? seconds : "0" + seconds);
    SpreadsheetApp.getActiveSheet().getRange('F7').setValue(stop_time); 
    Logger.log('set timer: %s', stop_time);
    documentProperties.setProperty('timer_result', stop_time);
}
</code></pre>