Hi All,
new Date() returns a date one hour later than current time.
I’m running my solution in Developer, both client and server on one machine.
The server page shows correct time on the server.
What’s wrong?
Cheers,
Maria
Hi All,
new Date() returns a date one hour later than current time.
I’m running my solution in Developer, both client and server on one machine.
The server page shows correct time on the server.
What’s wrong?
Cheers,
Maria
Are you running the solution in web client or smart client?
What is the value of “servoy.use.client.timezone” property in servoy.properties?
How did you see the date value created with new Date()? In a field, via application.output(…) or some other way?
What version of Servoy are you running?
Andrei Costescu:
Are you running the solution in web client or smart client?
What is the value of “servoy.use.client.timezone” property in servoy.properties?
How did you see the date value created with new Date()? In a field, via application.output(…) or some other way?
What version of Servoy are you running?
Ok…
Cheers,
Maria
Maybe the developer (that means both server and smart client under developer) is running in a different timezone.
Please check you smart client preferences to see if the default timezone that is set explains what is happening (that timezone will also be the timezone of the server under developer).
Hello,
Have this issue when running WebClient 5.2.15
new Date() gives the time on the server (what makes sense in basic theory as WebClient code is running server-side) but need there client’s datetime as I configure certain time on the client and than when time matching on server action is triggered. Can do only if client & server are in same timezone (client’s -user friendly).
servoy.use.client.timezone is true
WebClientUtils is suggested by Patrick in other thread, is that the optimal way to get client time zone’s new Date()?
https://www.servoyforge.net/projects/webclientutils
Regards
So do you want the time as reported by the client’s OS or the client’s time computed based on client timezone and server time?
Thanks Andrei, good point
Option 2 (server time in client’s timezone) has been built
-collecting offset on form’s onShow() event
var js = "var d = new Date();var offset = d.getTimezoneOffset();";
plugins.WebClientUtils.executeClientSideJS( js, globals.callbackOffset, ['offset'] );
-dividing collected offset with 60
-subtracting the hours from server hours
date.setHours(date.getHours() - forms.frm_time_zone_sync_server_client.offset )
Let me know if this is completely generic and/or if anyone have better (optimal) work-flow, please
Regards
You should get the same result from application.getTimestamp() since 6.0.8 (SVY-2726).
Before - in 5.x - it either simply returned a new Date() which isn’t helpful for WC or in later versions it would not always be correct depending on the type of client and servoy.use.client.timezone.