PxPlus User Forum

Twitter Twitter Twitter

Author Topic: A simple way to display a clock in your application  (Read 1759 times)

Mike King

  • Diamond Member
  • *****
  • Posts: 3811
  • Mike King
    • View Profile
    • BBSysco Consulting
A simple way to display a clock in your application
« on: April 06, 2020, 10:24:15 AM »
We recently had a client who wanted to display the current time of day on the screen from within his application.  While there are a vast number of free standing utilities to do this, we thought we'd present a simple suggestion as to how to accomplish this.

Before we start, we would like to review one thing you want to keep in mind.  While Nomads provides Timer functionality that you could easily use to update your screen every second, this is something you probably DON'T want to do especially if you are running remotely.  Each update of the time would need to send a packet from the server to the workstation, and while if you only have one or two workstations a couple of packets each second would not likely be a problem, consider if you have 100 workstations.  Having the system send out 100 updates every second and receive the packet acknowledgement would put a significant load on the system and network -- just for the sake of displaying the time.

So what we would suggest is that you use a clock that gets updated locally.

Here is a simple suggestion:

Use a web based clock inside a *browser control on your screen.  There are numerous styles of web based clocks available for free at places such as https://www.timeanddate.com/clocks/free.html.  You simply need to create the *browser control on your panel and create a dummy web page to load the desired clock. 

Now if the workstations don't have Internet access, you can create a clock yourself using the code found at https://www.dyclassroom.com/web-project/html5-how-to-create-a-simple-clock-using-javascript for a simple textual time display or for a more graphical display try the logic found at https://www.w3schools.com/graphics/canvas_clock_start.asp.


Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com