Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Apps Script: Increase time by 30 mins

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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')
    
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading