Get browser timezone offset


I need to get the user’s local timezone offset via the browser in my Vaadin 12.0.0 application. I tried retrieving the WebBrowser object for the session but the timezoneOffset is always 0 and the timeZoneId is null. Is this a bug or am I going about this the wrong way?

Browser is Chrome, I can see that the offset is provided by Chrome when I run the following JavaScript code snippet:

var offset = new Date().getTimezoneOffset(); console.log(offset);


Hi, it looks like a bug. VaadinSession.getCurrent().getBrowser().getTimezoneOffset() always returns 0 for me too. Can you please file a new issue?

Here’s a workaround:

public class MainView extends VerticalLayout {

    private int timeZoneOffset;

    public MainView() {
                "$0.$server.setTimeZoneOffset(new Date().getTimezoneOffset());", getElement());


    public void setTimeZoneOffset(int timeZoneOffset) {
        this.timeZoneOffset = timeZoneOffset;

    private void initLayout() {"TimeZoneOffset: " + timeZoneOffset);


Thanks for that Alejandro, I logged a bug

I’ll use your workaround in the meantime.


Hi !
Workaround not good enough for me because I use the getRawTimezoneOffset() vaadin 8 function


also, my call is not performed from a DIV element…

Seems that there’s still no fix in Vaadin 14 …