Current timezone / IP Adress

I’m looking to convert timezones from the logged in user/client to a specified timezone, in order to successfully do this I would need the client ip address or the user timezone. Is there a way in weweb that this information is available/bindable to a workflow so that I can make this work?

This is what the API would look like: ```
? api_key = YOUR_API_KEY
& base_location = Los Angeles, CA
& base_datetime = 2020-05-01 07:00:00
& target_location = Oxford, United Kingdom

If you want the timezone one option is accessing the browser one. You can use a custom formula for that:

  const DEFAULT_TIMEZONE = "Europe/London";
  let timezone;
  try {
    timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  } catch (e) {
    timezone = DEFAULT_TIMEZONE;
  return timezone;

The timezone returned in this way is just the browser one and may not be the same as the physical location of the user (e.g. the user can travel but does not update the device locale).

In my experience if the exact timezone is critical to the app logic it is better to ask the user for it (assuming the user understands timezones, which is not always the case).

1 Like