Getting time (milliseconds) in LCB

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
pklum
Posts: 26
Joined: Fri Jan 17, 2025 6:47 pm
Contact:

Getting time (milliseconds) in LCB

Post by pklum »

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
Emily-Elizabeth
Posts: 239
Joined: Mon Jan 03, 2022 7:10 pm
Contact:

Re: Getting time (milliseconds) in LCB

Post by Emily-Elizabeth »

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
victoriasmith
Posts: 2
Joined: Sun Nov 08, 2026 10:06 am

Re: Getting time (milliseconds) in LCB

Post by victoriasmith »

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.
Post Reply