PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: John DeStefano on September 19, 2018, 05:13:52 PM

Title: client time
Post by: John DeStefano on September 19, 2018, 05:13:52 PM
Hi all,

We are using the function dte(0) to print the time on some forms and reports.  We also use it to capture and record events in data files.

e.g.  dte(0:"%hz:%mz %P")

We have a customer that has locations in multiple time zones.  The dte(0) function uses the server time.  We have users logged into the server with their client in a different time zone.

Is there a function that will return the client time and not the server time?

We are using PXPlus 13.10 running on a Windows Server 2012 and we are not using WINDX. Users connect to the server using an RDP connection.

Title: Re: client time
Post by: Devon Austen on September 20, 2018, 08:51:10 AM
Have you tried:

Code: [Select]
EXECUTE "[WDX]dte(0:"%hz:%mz %P")"
or if the code also needs to run not on windx

Code: [Select]
EXECUTE "[LCL]dte(0:"%hz:%mz %P")"
Title: Re: client time
Post by: Mike King on September 20, 2018, 09:18:59 AM
Since you are using RDP and not WindX I don't know of anyway to find the users true workstation time zone.  When you connect using RDP the processes all run on your server and all the workstation does is handle display/input.  There is no real way to run anything locally to determine the time zone.

Now there may be an Windows API you could call in the windows WTS library ( https://docs.microsoft.com/en-us/windows/desktop/api/Wtsapi32/ ) but I did a quick look and couldn't see anything that would provide you what you are looking for.
Title: Re: client time
Post by: Devon Austen on September 20, 2018, 09:32:30 AM
I missed that you were not using Windx but RDP. What I suggested would only work if you are using WindX.

Mike is right that there is no easy way to get the client time when everything is running on the server except the RDP client.
Title: Re: client time
Post by: David Reynolds on September 20, 2018, 10:23:45 AM
I'm not sure if there's a Windows equivalent, but on Linux we use something like this...

Each user is assigned a location, and each location is assigned a time zone (matching those in /usr/share/zoneinfo)
So for local time we just issue:

Code: [Select]
READ RECORD("| TZ="+TZ$+" date +%Y%m%d%H%M%S")USERTIME$

where
Code: [Select]
TZ$="Canada/Pacific" ! or Canada/Mountain or Canada/Central or America/Toronto or Greenwich etc
Title: Re: client time
Post by: Mike King on September 20, 2018, 12:38:48 PM
A quick scan of the internet turned up the following link which may be of help to you:

https://serverfault.com/questions/634260/set-user-time-zone-by-gpo-on-windows-server-2012

It looks like you can configure the server to logically change the time for the session running on the host to that of the workstation (or at least that is how I interpreted this).
Of course now the problem may be for you to get the time zone of the host  ;D