6 Replies Latest reply on May 8, 2013 10:26 AM by hamrichards

    Get(CurrentTime) to 0.01 second in iOS?


      For timing athletic events using an iPad, I need a function that returms the current system time to the nearest 0.01 second (the precision of Get(CurrentTime) is one whole second).


      In OS X I'd use the script step Perform Applescript, but neither that step nor Install Plug-in File is available for iOS. Any leads would be appreciated.





        • 1. Re: Get(CurrentTime) to 0.01 second in iOS?

          Let (


                    UTCTIME = Get ( UTCmSecs ) ;

                    LOCALTIMESTAMP = GetAsTimestamp ( UTCTIME / 1000 + ( Get ( CurrentTimeStamp ) - Truncate ( UTCTIME /1000 ; 0 ) ) )

                    ] ;

                    GetAsTimestamp ( UTCTIME / 1000 + ( Get ( CurrentTimeStamp ) - Truncate ( UTCTIME /1000 ; 0 ) ) )


          • 2. Re: Get(CurrentTime) to 0.01 second in iOS?

            In case it isn't clear from user14047's description, Get ( UTCmSecs ) is an undocumented function in FileMaker 12 that returns the current UTC timestamp in milliseconds (expressed as the number of milliseconds since FileMaker's timestamp epoch, without being converted to a proper timestamp-type value). Don't get attached; since it's undocumented, there's a chance it may not be available in future versions of FileMaker. If your interest is strictly in timing the durations of athletic events as precisely as possible, rather than getting a timestamp in the local time zone, you can save yourself some latency by not doing the adjustment for time zone, at least when capturing the instantaneous time:


            Set Variable [$start; Value:Get ( UTCmSecs )]

            # ...

            Set Variable [$stop; Value:Get ( UTCmSecs )]

            Set Variable [$duration; Value:GetAsTime ( ( $stop - $start ) / 1000 ) // precise to 0.001]


            The real difference is probably negligible, but this is another approach.

            1 of 1 people found this helpful
            • 3. Re: Get(CurrentTime) to 0.01 second in iOS?

              Many thanks, user14047! Get(UTCmSecs) solves my problem perfectly. And I've confirmed that it works in FM GO as well as FM Pro.


              How did you discover the undocumented Get(UTCmSecs)? Is there a list of undocumented functions? (If there were, would they still be undocumented?)





              • 4. Re: Get(CurrentTime) to 0.01 second in iOS?

                Thanks, jbante, for your very useful and interesting elaboration.


                As you observe, for my purposes there's no need for conversion to type TimeStamp, because all I need is the difference between two successive values of Get( UTCmSecs ).


                In my application (rowing races), we'll put an iPad at each end of the 5000-meter course.  Each iPad will build up a table of boat IDs with their line-crossing UTCs, and each boat's time over the course will be computed in a laptop running the central FM Pro database.


                To minimize latency, as well as vulnerability to communication dropouts, I want to keep the {boatID,UTC} tables in the iPads, using them as remote data sources for the central database. If it works, this design relieves the iPad operators of any responsibility for sending their data to the central database.


                This being my first venture into FM GO, whether this is possible remains to be seen. If not, a decent Plan B would be an explicit import from each iPad to the central database.


                Again, thanks,



                • 5. Re: Get(CurrentTime) to 0.01 second in iOS?

                  In that case, be sure you thoroughly test the clock sync between iPads. It doesn't do any good to record time accurate to milliseconds if the iPad clocks are half a second apart!

                  • 6. Re: Get(CurrentTime) to 0.01 second in iOS?

                    Good point, but actually the iPads could be off by several seconds and no one would know (or would care if they did). The reason is that what determines which boats win and which ones lose are their relative times, which would be unaffected by a uniform error in their times over the course.


                    The only reason rowers and coaches care about absolute times over the course is that they like to compare their times in different races. But there are so many variableswind, current, steering precisionthat those comparisons are meaningful only if the differences are really big.


                    Just between you and me, the rowing community's expectation of two-decimal-place precision is not really warranted. The times are based on human beings clicking a button when they see a boat's bow crossing an imaginary line, and I'd be surprised if the error in that measurement is less than a few tenths of a second.