# Date time with maths?

I have 2 var’s im working with,

1 is the time in EST HH:mm tt [ input value example : 5:00 pm ]

the second is the gmt +/- of the client [ input value example : -2:00 ]

ignoring daylight saving issues, the goal is to take the time and display it in the clients local time.

for example , if i have a project starting at 6pm EST, and a client in a timezone of -1 gmt,
EST is -5gmt so i know the local time is 2pm for the client.

here is formula i use so far for int32 ( did this as a test )

[Assign] X = -5 (EST var )
[Assign] Y = -1 ( Local time )

[Assign] Result = math.abs(x - (y))

[If] (y.tostring).contains("-")
Result = z - Result

Else
Result = z + result

This seems to return the correct values, but its in int32. I cant seem to get it working with dateTime.

problem is some of the meetings are like, 16:15 etc, so int wont cut it. Any suggestions ?

Hello.

It’s normally better to adjust the dates as a DateTime value. So you can use `.AddHours()` and subtract or add the hours.

``````datetimevariable.AddHours(-4)
``````

That would take the 6pm down to 2pm

Does that help?

Regards.

1 Like

so something like :

projectTime = 17:00

var1 = -5
var2 = -2

var3 = math.abs(var1 - (var2))
[returns 3]

Result = projectTime.subtracthours(var3)

?

Not quite. There is not `.SubtractHours()` function. There is only `.Subtract()` or `.AddHours()`

.Subtract() requires a Timespan while .AddHours() just requires a number

There’s probably a number of ways to do this, but you could just convert the time to a DateTime with CDate(timestring) or Convert.ToDate(timestring). Then, you can use .AddHours()

``````projectTime <as DateTime> = Convert.ToDate("17:00")

``````

So it should look like `projectTime.AddHours(-3)`, and that will subtract the hours. As far as the math you are doing on the var1 and var2, I’m not completely sure why you are doing that, but hope the other stuff is helpful.

EDIT: also since it’s a DateTime it will include the date, so use `.ToString("hh:mm")` to output only the time.

Regards.

1 Like

ah that makes a lot of sense, thanks man.

The math is because the time is in EST time and im working vs the clients timezone which i have in gmt.

so if its 5pm est ( which is -5gmt ) and the clients timezone is -2 gmt, then I want the robot to say

“your project is at 2pm in your local time” to the client.

not sure if there is a simpler way to achieve this then what im doing ? i did have issues originally getting a double negative to work.

gotcha.

You can also use UniversalTime maybe.

For example:

``````var2 = -2