PricingBlog

Getting the user timezone from browser settings

  • okgo.-1186636560058306581

    okgo

    2 years ago

    Hi everyone! In my application I work a lot with dates and time. Now I would like to transform the standard dates with the "format date" function to the timezone that's set in user's browser. I tried to get this to work with some custom Javascript code, but I can't find any option to set the result to a variable that I can use in the formula editor. Any thoughts around this? Thanks. 🙂
    1
  • gazinhio-1186637764523999232

    gazinhio

    2 years ago

    Have you put the code in a custom formula or action? If it's a formula, you can use a Set Variable action in a workflow and set it to the result of your custom formula. If you need it to be set without a user interaction eg a click, you can use the Page Loaded lifecycle event.
  • okgo.-1186641329887924255

    okgo

    2 years ago

    Hi @! Thanks for your quick reply. Your input provided the extra info that helped me getting this to work, thanks!

    For future reference, this is the Javascript that I used in the custom formula:

    return new Intl.DateTimeFormat(undefined, {}).resolvedOptions().timeZone;
    👍1