Get client local time on server

I made my portlet and there I have to present diference between server time and client local time.
I tried to do this by this code:

Date serverTime = new WebBrowser().getCurrentDate();
long localTime = System.currentTimeMillis();

but both this function return the same time - time on server.

Is anybody know how to get client local time?

1 Like

WebBrowser.getCurrentDate() should work (based on an measurement/estimation of the time difference between server and client, returning the time in the server’s time zone).

However, you can also check WebBrowser.getTimezoneOffset() and WebBrowser.getRawTimezoneOffset(). You can then get GMT time from the server and apply the adjustment getTimeZoneOffset() assuming the client computer is correctly configured.

1 Like

What if the user changes their local time and they are on a completely different date? For example, for testing. Can we get the actual time, not assuming that it is in sync with the server time?