Can you get the user's timezone in a Server Connect step?

Just wondering if there is a way in Wappler to get the users time zone based on a step in Server Connect, something like 'Australia/Melbourne' or +11 etc.

The reason for this is that I have a query that is running that needs to use a time zone in some of the conditions and i think its better if i keep this server action all on the server side rather than add it into App Connect and get user inputs from there (which would have the users time zone)

If nothing exists, i might look at if there are some modules/libraries on Github that could be added in as a custom module.

You could use UTC as explained in:

Thanks @ben, As far as I can tell though, that’s all fort for client side / app connect.

I’m just looking for a way to do it in a server connect step rather than involve anything in app connect or the user’s input.

I thought to use the to use Set Value using Now and then toLocalTime but that isn’t converting the NOW to the local time.

Have you tried Time UTC on the server side?

image

Yes, i did try a few things there but nothing worked as expected…perhaps its a bug?

Here is a sevrer action with 4 different variations of setting a value with the NOW feature, and then trying to convert to a local time.

The end result is 4 identical times?

{"NOW":"2020-11-03T06:54:51",
"NOW_UTC":"2020-11-03T06:54:51",
"NOW_toLocalTime":"2020-11-03 06:54:51.0",
"NOW_UTC_toLocalTime":"2020-11-03 06:54:51.0"}

At the time running these (just now) the time was 17:54

@Teodor. Is this working as expected with a Node project?

Server action stuff is all on the server side. Since you do not wish to put any client side interaction (like GET or POST inputs), there is no way to know details like timezone of client for which the API call has been made. You can look into the request HEADERS for time, but I am not sure if that is sent in Wappler, and even if it is, weather it is in local timezone or UTC.

What I would suggest is to send in the timezone or time value from the client side at the time of login (if you have one), and store that in server session variable.
From there, you can just use those session variables in any server action you want.

This means that your server is probably set to UTC time zone by default.

Ok. I did think that might be the case…i.e. without a client action no way for server action to determine timezone.

I began looking at alternates anyway, and session variables may be an option or its something that might be suited to be stored in a DB anyway based on this specific application