Hi,
I have tried to get the milliseconds in LCB, but failed every atempt.
How do I get milliseconds or seconds in the best way?
Best Regards
Peter
Getting time (milliseconds) in LCB
-
Emily-Elizabeth
- Posts: 239
- Joined: Mon Jan 03, 2022 7:10 pm
- Contact:
Re: Getting time (milliseconds) in LCB
You'd have to do some math, but looks like there is a function to get the seconds from the epoch
https://docs.livecode.com/docs/LiveCode ... versalTime
https://docs.livecode.com/docs/LiveCode ... versalTime
-
victoriasmith
- Posts: 2
- Joined: Sun Nov 08, 2026 10:06 am
Re: Getting time (milliseconds) in LCB
Peter, the epoch-seconds function is the practical starting point. Multiply the returned seconds by 1000 for milliseconds; for higher precision you'll need to combine it with a sub-second timer and do the arithmetic yourself, since the function alone won't give fractional milliseconds. Keep the multiplication explicit so it's clear where the conversion happens. If you only need elapsed time rather than a wall-clock timestamp, a timer is usually a simpler and more reliable choice than working from epoch values.
Re: Getting time (milliseconds) in LCB
Hi,
Thank you!
Will look into your recommendation.
Regards,
Peter
Thank you!
Will look into your recommendation.
Regards,
Peter
-
PaulDaMacMan
- Posts: 697
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Getting time (milliseconds) in LCB
Microseconds, more precise but if you need milliseconds you could always get 'the millseconds' by evaluating script from LCB:
Then coerce to an a numeric type if you need to.
Although using 'the universal time' and then doing the math would probably be faster for this.
Code: Select all
execute script "return the milliseconds"
Code: Select all
variable tNum as optional Number
execute script "return the milliseconds"
put the result parsed as number into tNum
Best 'trick', out of many, that I picked up from the great Herman Hoch (R.I.P.)Note: An error is thrown if this syntax is used in a context where access to script objects is not allowed.
Although using 'the universal time' and then doing the math would probably be faster for this.