Skip to content
Advertisement

How to get time according to the offset provided by the user in google apps script?

I have been trying to convert time in google sheet cell according to the offset provided by the user. Here is an example:

Cell A1(Current): 01:00 AM
Cell A2(offset) : -5
Cell A3(Desired): 08:00 PM

Is there any method using which we can convert cell A1 into cell A3? Thank you

Advertisement

Answer

You can try this in A3:

=TIMEVALUE(A1) + (A2/24)

You will need to format A3 as hh:mm am/pm.

It’s not clear why you need a script to accomplish this task. But if that is the case for some reason, I recommend that you add that reasoning to your post. Many users (particularly new ones) on this forum include the word “script” in their headlines or posts when they don’t really know what one is, why they’d need one, or the difference between “script” and “formula”; so the volunteer contributors here will often provide the easiest/quickest route to the solution (which is the formula).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement