Thanks S Chamblee. I've been kicking myself for a long time for not adding a note on this function into Tutorials in my Known Bugs List database so that I could find it when I needed it. Now I have the info stored for future use.
A few words of caution: any undocumented feature is "use at your own risk". We don't know how thoroughly it was tested and it could easily disappear or change how it works in future releases without any warning from FileMaker.
But Get ( UTCmSecs )/1000 will do nicely to return the needed time stamp.
But if you want to avoid the Undocumented function, you can also use Get ( CurrentTIme ) or Get ( CurrentTimeStamp ) to compute the same time if you include an adjustment based on the timezone specified in your locality settings.
Thanks S Chamblee. I appreciate the tip.
Thanks PhilModJunk for your update. The pilot friend needs this function as he flies around the world, so for him, it is simpler to base everything on Zulu time instead of trying to get the local timezone and then covert everything when he returns home.
Oops! I spoke too soon. Now when I click on the button using the function:
Get ( UTCmSecs ) / 1000, the field beside it (called cal_z_start) doesn't show the time, in fact it doesn't show anything.
Could someone walk me through this right from the beginning please?
I would like the first button, which has the label "Zulu Start", when clicked to display the current UTC time in a field called cal_z_start.
I would like the second button, which has the label "Zulu End", when clicked to display the current UTC time in a field called cal_z_end, (presumably after the start time)
I would also like a third field called z_differ, to calculate the difference.
I'm sure I've probably put a character in the wrong place but I just can't see it.
The function produces a time stamp--the current date and time, not just the time. Use the expression to put data into a field of type timestamp not time.
Or put it inside a getastime function to extract the time in order to put it in a field of type time. GetAsTime ( Get ( UTCmSecs )/1000 )
The pilot friend needs this function as he flies around the world, so for him, it is simpler to base everything on Zulu time instead of trying to get the local timezone and then covert everything when he returns home.
That's not quite what I had in mind. If you take your lap top around the world, the system clock does not change unless you update its locality settings. It should still show the time form your pilot's "home base". Thus you can set up to add/subtract a constant number of hours from the system clock's time to get UTC time.
I haven't traveled enough to know if an iOS device automatically adjusts for the local time zone, but if it doesn't, it should also work the same way.
Thanks again PhilModJunk,
I tried as you suggested but I am still not showing anything in the field.
So, sorry to be so pedantic but could someone walk me through step by step how to create the button and put it in to the field next to it.
I am so frustrated, I know it is something like a character in the wrong place but I can't find it.
The set field step you use--either as a button option or as a step in a script performed by a button should have this format:
Set Field [YourTable::yourTimeStampField ; Get ( UTCmSecs )/1000 ]
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
Thanks again PhilModJunk,
Yes, it was me putting in the wrong thing. However, now when I put the time in it shows something like:
I have tried both ways, either as a timestamp or as a time field. How do I get it to show just the 4 time numbers such as 17:28.
I would also like it to show as 17:28Z. Is this possible?
I had to play with it a bit to get just the time (I'd think that a TimeStamp would make more sense...):
getastime ( Getastimestamp ( get ( UTcmsecs )/1000 ) )
You can certainly use data formatting in the inspector to get 24 hour HH::MM format. And in that same area of the inspector, you can specify a z as a trailing character after the time.
Thanks yet again, PhilModJunk,
Your answer was perfect. I did as you suggested and formatted the field with a trailing z.
One last question on this:
Is this something that should be put forward as a request so that is not an undocumented feature?