Brian Dunning's FileMaker Custom Functions

GetAsFMTimestamp ( source )

Converts any date or timestamp (including Unix and ISO) to a valid FileMaker formatted timestamp

  Be the first to rate this function Log in to vote

Kyle Williams   Kyle Williams - Show more from this author
Augusto Digital
https://www.youtube.com/channel/UCpJlB7cmVNMjbjgY96MEsng

Share on Facebook Share on Twitter

  Sample input:
GetAsFMTimestamp (Get(CurrentDate)) // "9/12/2019"
GetAsFMTimestamp ( "9/12/2019 12:00" ) // Incomplete timestamp
GetAsFMTimestamp (2019-09-12T00:00:00Z")// UTC Timestamp
GetAsFMTimestamp ( 1568320785 ) // Unix Timestamp
  Sample output:
9/12/2019 12:00 AM
9/12/2019 12:00 PM
9/12/2019 12:00 AM
9/12/2019 1:39:45 PM

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Very useful if a timestamp is not entered quite right, or you need to convert a date stamp to a timestamp, or you want to convert Unix or UTC timestamps to an FM Timestamp.

I developed this because a lot of APIs and other applications will use a variety of timestamps and this will convert them all to something that FileMaker can use.

 

Comments

Mark Hodgins   Mark Hodgins, Michigan State University
Sep 1, 2022
Kyle - trying to run your function and it is failing on this section:
isUnix;
GetAsTimestamp ( (GetAsNumber (Left(source; 10)) )
+ GetAsNumber (Timestamp ("01/01/1970" ; "00:00:00"))
+ GetAsNumber ( Get(CurrentTimestamp) )
//Adjust for local timezone:
- Floor ( Get(CurrentTimeUTCMilliseconds)/1000) );
with the error "This parameter [CurrentTimeUTCMilliseconds] is an invalid Get function parameter. I have the TimeFormatAs function loaded as referred to in the header of the code. Am I missing something else?
 
Kyle Williams   Kyle Williams, Augusto Digital
Sep 1, 2022
Hi Mark, I have since updated my function to support millisecond timestamps but it seems I never updated it here in BrianDunning's site.. I have now updated it with a more recent version.
 
Kyle Williams   Kyle Williams, Augusto Digital
Sep 1, 2022
FYI, the Get(CurrentTimeUTCMilliseconds) function has been around since v13 so I'm not sure why you would be getting that message unless you are using v12 or earlier.. https://help.claris.com/en/pro-help/content/get-currenttimeutcmilliseconds.html
 
Kyle Williams   Kyle Williams, Augusto Digital
Sep 1, 2022
FYI, the Get(CurrentTimeUTCMilliseconds) function has been around since v13 so I'm not sure why you would be getting that message unless you are using v12 or earlier.. https://help.claris.com/en/pro-help/content/get-currenttimeutcmilliseconds.html
 
Mark Hodgins   Mark Hodgins, Michigan State University
Sep 7, 2022
Thanks Kyle. Sorry to bother you. I was on an older version. Jumped onto newest version and was successful running the function. Appreciate the quick turn-around. My timestamps are now correct.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: