58
Views
10
Comments
Solved
How to get time in milliseconds

I am trying to make some experiments, and measure the time for some block to render, find which block rendered first, and measure fetch time of data. However, the "CurrDateTime()" function only returns the time to the nearest second. I want to measure the time by milliseconds to be more accurate.

2025-01-24 02-53-49
Mustafa Emad Shaker
Solution

From what I understand from your question, all you are trying to measue would be from client side only. So, you could use JavaScript to get time in milliseconds.

The date object in JavaScript contains functions that return data form current year to milliseconds. All you need to do is define it and return the timestamp form it.

Here is the syntax:

We can an extra step and make a client function that return the timestamp in the format of 
"yyyy-mm-dd hh:mm:ss.msg".

You can find simple demo (doc "Timestamp.oap") is attached to this comment.

Timestamp.oap
2025-04-19 12-12-35
Maya Sameh
2025-01-24 02-53-49
Mustafa Emad Shaker
Solution

Hi @Maya Sameh,

I just realized a minor issue in the solution I provided. I put the milliseconds value before the '0' augmentation, it should be after.

Regards.

2025-04-19 12-12-35
Maya Sameh

Hello @Mustafa Emad Shaker,

I did notice it, but assumed it was just a typo. Thanks again for clarifying this point.

Regards.

2025-01-24 02-53-49
Mustafa Emad Shaker
Solution

Hi @Maya Sameh,

I just realized a minor issue in the solution I provided. I put the milliseconds value before the '0' augmentation, it should be after.

Regards.

2025-01-24 02-53-49
Mustafa Emad Shaker
Solution

From what I understand from your question, all you are trying to measue would be from client side only. So, you could use JavaScript to get time in milliseconds.

The date object in JavaScript contains functions that return data form current year to milliseconds. All you need to do is define it and return the timestamp form it.

Here is the syntax:

We can an extra step and make a client function that return the timestamp in the format of 
"yyyy-mm-dd hh:mm:ss.msg".

You can find simple demo (doc "Timestamp.oap") is attached to this comment.

Timestamp.oap
2025-04-19 12-12-35
Maya Sameh
2025-01-24 02-53-49
Mustafa Emad Shaker
Solution

Hi @Maya Sameh,

I just realized a minor issue in the solution I provided. I put the milliseconds value before the '0' augmentation, it should be after.

Regards.

2025-04-19 12-12-35
Maya Sameh

Hello @Mustafa Emad Shaker,

I did notice it, but assumed it was just a typo. Thanks again for clarifying this point.

Regards.

2025-12-22 13-50-43
Sherif El-Habibi
Champion

Hello Maya,

Mustafa’s approach is absolutely on point. Just a little addition if you prefer a more direct approach, there’s a Forge component that returns the current date with milliseconds:

https://www.outsystems.com/forge/component-overview/5153/get-date-time-with-milliseconds-o11



2025-04-19 12-12-35
Maya Sameh
2025-12-22 13-50-43
Sherif El-Habibi
Champion
2025-01-24 02-53-49
Mustafa Emad Shaker

@Maya Sameh,

I am not sure it you wanted to measure the execution time from client side or server side, but I assumed that it was client side.

If what you meant was server side, then the forge component @Sherif El-Habibi mentioned would do the job, since we cannot execute Js code from server side.

Regards.

2025-04-19 12-12-35
Maya Sameh

Yes indeed I was trying to measure the time difference from client side, that is why I marked your answer as the solution.

The other solution by Sherif also worked, but I used it to test server actions more.

Reagrds.

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