32
Views
13
Comments
[JS-StopWatch] Start and stop clock and track time
js-stopwatch
Reactive icon
Forge asset by Sourabh sharma
Application Type
Reactive
Service Studio Version
11.55.1 (Build 63862)

Hello Team ,

 I am trying to use stopwatch forge asset, it seems working good , but when I refresh the page the time is resetting to zero.

I want to use the clock where it tracks the total time and saves it in DB when I stop it manually , ( it could be after 2hrs or 5hrs , or even a day later ) if I navigate to different screen or logout also the clock should be running till I press some button. 

Please suggest solution.


Thanks in advance

Nandini 


2025-12-15 09-29-24
Thibaut G

Hi,

Since you want the timer to keep running, you will need to track the time on the server instead of the client.

For example, you could save the current datetime  in the database the moment the button is pressed. 

The visualized value of your front end timer component  would be the time difference between the datetime that was stored in the DB the moment the timer was started and the current datetime.

Does each user need a personal timer, or is the timer global for every possible user? 
If it is specific to a user, you can also store the UserId in the database together with the START datetime so that you can differentiate between users.

Hope this helps !

Kind regards

Thibaut 

2026-03-06 04-24-49
Nandini Ts

Hi Thibaut,

Thank you for your suggestion, 

I want to implement for each user and when user logs in the timer should be running and user should see that on the screen in the format hh:mm:ss.

If you have any example please share.


2024-09-12 02-43-38
Deepsagar Dubey

Hi @Nandini Ts 

Would you clear below points - 

1. When you want to start time i.e. when users logged in or when user pressed any button ?
2. The timer can be start only when user logged in ? 

Meanwhile, Let's consider only logged in users can start and stop timer then create an entity with these possible attributes

UserTimeTracker

    Id

    UserId

    Status (Started or Stopped) - Maintain records in a statc entity

    StartedOn - DateTime when user started 

    StoppedOn - DateTime when user stopped (default is Null date)

   

Make sure user have only one active time tracker at a time, you can manage it with status attribute, 

To display time difference on page use JavaScript code using setInterval for every second.

i hope it'll help you.

Thanks
Deep

   

2026-03-06 04-24-49
Nandini Ts

Thanks for your reply...

Yes I can track the time by using an entity when certain button is pressed, 

But the time should be running and should be visible I.e., like e.g., :- you started your work since 00:34:21

When user want to complete his task he can see the time that when he started and since when he is working on that...

1. I want to start time when the button is pressed 

2. Only logged in user can start and stop

2024-09-12 02-43-38
Deepsagar Dubey

Yes, so in this case you don’t need to use any component you can achieve it just by writing your logic and for refresh timing simply use java script setinterval method,

You can create a web block put your code there and call that web block on screens where you want to show timing, so it’ll not affected even you refresh or change the screen.

UserImage.jpg
Nani

Check the Oml i have updated a Javascript , so you can set stop watch timer.

so, the customize the time based on the user.

I hope this helps you.

thank you.


StopTimer.oml
UserImage.jpg
Nani

Sorry, Re updated the code check oml.

StopTimer.oml
2026-03-06 04-24-49
Nandini Ts

Hello Nani, 

Thanks for your reply , but the timer is resetting after screen refresh , but the timer should not reset until it is explicitly stopped. because I want to track the total time it has run

UserImage.jpg
Nani

Check new features are added in the latest version of StopWatch.

Please download the latest version from the forge.

2026-03-06 04-24-49
Nandini Ts

Could you please link the forge component here , 

The asset which I linked is same as previous and not working as expected.


Thanks

UserImage.jpg
Nani

This is the link: https://www.outsystems.com/forge/component-versions/13395/version/34360/platform/11

I don't know why is not showing in service studio forge, but it is showing in browser in  version's tab , so you can download the latest version and open file in service studio.

But after deleting the application in service studio it showed me the latest version may there is some bug.

2022-07-03 17-24-08
Sourabh sharma

Hi @Nandini Ts,

As I have seen your additional requirements for the Forge Component , let me pick the all your given requirements and implements in the next updated version. 

Thank you @nani to update in the components gave in OML.

kind Regards.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.