Home > OS >  Apps Script: Increase time by 30 mins
Apps Script: Increase time by 30 mins

Time:12-19

I guess I am getting too tired and should jump into bed instead of drinking more coffee. Anyway, all I want to do is increase the current output (so, 13:30) of the variable below by 30 mins. Any idea how to achieve this? Thanks :).

let startTime = Utilities.formatDate(new Date(data[0][6]), 'GMT 1', 'HH:mm');

CodePudding user response:

In your situation, how about the following modification?

Modified script:

let startTime = Utilities.formatDate(new Date(new Date(data[0][6]).getTime()   (30 * 60 * 1000)), 'GMT 1', 'HH:mm');
  • In this case, 30 minutes are added to new Date(data[0][6]). If data[0][6] is the date object, you can modify it as follows.

      Utilities.formatDate(new Date(data[0][6].getTime()   (30 * 60 * 1000)), 'GMT 1', 'HH:mm')
    
  • Related